-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbig_integer.h
More file actions
53 lines (38 loc) · 1.4 KB
/
big_integer.h
File metadata and controls
53 lines (38 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#ifndef BIG_INTEGER_H
#define BIG_INTEGER_H
/*
** big_integer.h
** Description: "Arbitrary"-precision integer
** Author: Andre Azevedo <http://github.com/andreazevedo>
**/
#define BIG_INTEGER_DATA_MAX_SIZE 8
typedef struct BigIntegerData
{
unsigned int bits[BIG_INTEGER_DATA_MAX_SIZE];
int length;
} BigIntegerData;
typedef struct BigInteger
{
char sign;
BigIntegerData data;
} BigInteger;
/* creates a big integer number */
BigInteger big_integer_create( long long value );
/* returns the big integer as int */
int big_integer_to_int( const BigInteger bigInt );
/* returns the big integer as long long */
long long big_integer_to_long_long( const BigInteger bigInt );
/* compare big integers */
int big_integer_compare( const BigInteger left, const BigInteger right );
/* adds two big integers together ( left + right ) */
BigInteger big_integer_add( const BigInteger left, const BigInteger right );
/* subtracts one big integer from another ( left - right ) */
BigInteger big_integer_subtract( const BigInteger left, const BigInteger right );
/* increments the bigInteger by the amount specified */
void big_integer_increment( BigInteger *bigInt, const unsigned int value );
/* decrements the bigInteger by the amount specified */
void big_integer_decrement( BigInteger *bigInt, const unsigned int value );
#ifdef DEBUG
void big_integer_dump( const BigInteger bigInt );
#endif
#endif /* BIG_INTEGER_H */