* Fix for print unrecognized node
[biginteger-lo27.git] / biginteger_utils.h
blobacd0bddab833530b0a9fe4dcbf3b7e9cb7d7b4b1
1 /* Copyright (c) 2008 Jérémie Laval, Marine Jourdain
3 * Permission is hereby granted, free of charge, to any person obtaining a copy
4 * of this software and associated documentation files (the "Software"), to deal
5 * in the Software without restriction, including without limitation the rights
6 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 * copies of the Software, and to permit persons to whom the Software is
8 * furnished to do so, subject to the following conditions:
10 * The above copyright notice and this permission notice shall be included in
11 * all copies or substantial portions of the Software.
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 * THE SOFTWARE.
23 #include <stdlib.h>
24 #include "biginteger.h"
26 #ifndef _BIG_INTEGER_UTILS_H
27 #define _BIG_INTEGER_UTILS_H
29 // Macros
31 #define ATOUI(str) ((unsigned int)strtoul(buffer, NULL, 10))
32 #define MIN(x, y) (x < y ? x : y)
33 #define MAX(x, y) (x > y ? x : y)
35 // Private Function Declaration
37 BigUnsignedInteger* ReturnNthNode(BigInteger*, int);
39 BigInteger CreateZeroBigInt();
41 BigUnsignedInteger* InitBUint(unsigned int);
43 BigUnsignedInteger* CopyBigInteger(BigInteger source, BigInteger* dest, BigUnsignedInteger* start, int count);
45 BigUnsignedInteger* CopyBigIntegerFromEnd(BigInteger source, BigInteger* dest, BigUnsignedInteger* start, int count);
47 BigUnsignedInteger* ReplaceFromEnd(BigInteger* source, BigInteger slice, BigUnsignedInteger* start, int count);
49 void Clean(BigInteger* b);
51 void SplitBigInteger(int N, BigInteger base, BigInteger* part1, BigInteger* part2);
53 void MultiplyByBase(BigInteger* b, int k);
55 void PrependNode(BigUnsignedInteger*, BigUnsignedInteger*);
57 void PushFrontNode(BigInteger*, unsigned int);
59 void PushEndNode(BigInteger*, unsigned int);
61 void InsertNode(BigInteger*, BigUnsignedInteger*, unsigned int);
63 unsigned int GetValueAtFromEnd(BigInteger b, int i);
65 BigInteger mulBigIntByScalar(BigUnsignedInteger* big, unsigned int multiplier);
67 BigInteger powBigInt(BigInteger b, int n);
69 // End Private Function Declaration
71 #endif