-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbigint.h
49 lines (40 loc) · 1.44 KB
/
bigint.h
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
#ifndef BIGINT_H
#define BIGINT_H
#include "math.h"
#include "string.h"
#include "stdbool.h"
#include "limits.h"
#include "time.h"
#include "assert.h"
#include "constants.h"
#ifdef __CYGWIN__
#include "alloca.h"
#endif
#define expoBias (0x7FFFFFFF) //this value is subtracted from actual exponent
typedef struct
{
u64* val;
int size;
} BigInt;
MANDELBROT_API BigInt BigIntCtor(int size);
MANDELBROT_API BigInt BigIntCopy(BigInt* bi);
MANDELBROT_API void BigIntDtor(BigInt* bi);
//dst must have exactly twice the width of lhs and rhs
MANDELBROT_API void bimul(BigInt* dst, BigInt* lhs, BigInt* rhs); // generic (asm)
MANDELBROT_API void bimulC(BigInt* dst, BigInt* lhs, BigInt* rhs);
//biadd returns true if a carry bit overflowed
//dst, lhs and rhs must have same size for add, sub
MANDELBROT_API void biadd(BigInt* dst, BigInt* lhs, BigInt* rhs); //returns 0 iff no overflow
MANDELBROT_API void bisub(BigInt* dst, BigInt* lhs, BigInt* rhs); //subtract rhs from lhs; result >= 0
MANDELBROT_API void biinc(BigInt* op);
MANDELBROT_API void bishlOne(BigInt* op);
MANDELBROT_API void bishl(BigInt* op, int bits);
MANDELBROT_API void bishr(BigInt* op, int bits);
MANDELBROT_API void bishrOne(BigInt* op);
MANDELBROT_API void biTwoComplement(BigInt* op);
MANDELBROT_API void biPrint(BigInt* op);
MANDELBROT_API void biPrintBin(BigInt* op);
MANDELBROT_API bool biNthBit(BigInt* op, int n);
MANDELBROT_API int lzcnt(BigInt* op);
void profiler();
#endif