BIN
bigint/build/bin/testbip
Executable file
BIN
bigint/build/bin/testbip
Executable file
Binary file not shown.
60
bigint/build/include/bigint.h
Normal file
60
bigint/build/include/bigint.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* bigint.h -- big integer library
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _BIGINT_H_
|
||||
#define _BIGINT_H_
|
||||
|
||||
|
||||
/* object representation */
|
||||
typedef void* BigObjRef;
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
typedef struct {
|
||||
int nd; /* number of digits; array may be bigger */
|
||||
/* nd = 0 exactly when number = 0 */
|
||||
unsigned char sign; /* one of BIG_NEGATIVE or BIG_POSITIVE */
|
||||
/* zero always has BIG_POSITIVE here */
|
||||
unsigned char digits[1]; /* the digits proper; number base is 256 */
|
||||
/* LS digit first; MS digit is not zero */
|
||||
} Big;
|
||||
|
||||
#include "support.h"
|
||||
|
||||
|
||||
/* big integer processor registers */
|
||||
|
||||
typedef struct {
|
||||
BigObjRef op1; /* first (or single) operand */
|
||||
BigObjRef op2; /* second operand (if present) */
|
||||
BigObjRef res; /* result of operation */
|
||||
BigObjRef rem; /* remainder in case of division */
|
||||
} BIP;
|
||||
|
||||
extern BIP bip; /* registers of the processor */
|
||||
|
||||
|
||||
/* big integer processor functions */
|
||||
|
||||
int bigSgn(void); /* sign */
|
||||
int bigCmp(void); /* comparison */
|
||||
void bigNeg(void); /* negation */
|
||||
void bigAdd(void); /* addition */
|
||||
void bigSub(void); /* subtraction */
|
||||
void bigMul(void); /* multiplication */
|
||||
void bigDiv(void); /* division */
|
||||
|
||||
void bigFromInt(int n); /* conversion int --> big */
|
||||
int bigToInt(void); /* conversion big --> int */
|
||||
|
||||
void bigRead(FILE *in); /* read a big integer */
|
||||
void bigPrint(FILE *out); /* print a big integer */
|
||||
|
||||
void bigDump(FILE *out, BigObjRef bigObjRef); /* dump a big integer object */
|
||||
|
||||
|
||||
#endif /* _BIGINT_H_ */
|
||||
15
bigint/build/include/support.h
Normal file
15
bigint/build/include/support.h
Normal file
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* support.h -- object representation and support functions
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _SUPPORT_H_
|
||||
#define _SUPPORT_H_
|
||||
|
||||
/* support functions */
|
||||
|
||||
void fatalError(char *msg); /* print a message and exit */
|
||||
void * newPrimObject(int dataSize); /* create a new primitive object */
|
||||
void * getPrimObjectDataPointer(void * primObject);
|
||||
|
||||
#endif /* _SUPPORT_H_ */
|
||||
BIN
bigint/build/lib/libbigint.a
Normal file
BIN
bigint/build/lib/libbigint.a
Normal file
Binary file not shown.
Reference in New Issue
Block a user