The library will be fully open source once I'm satisfied that it's working properly. I'm writing it in C that's as portable as I can make it so it should work on pretty much any 32- or 64-bit system.
As far as usage is concerned, this small test program in C is linked to the library:
Code:
#include <stdlib.h>
#include <stdio.h>
#include "decfp.h"
void prt(_NUM*);
int main(int argc, char** argv) {
_NUM x, sn, cs, tn;
RealToNum(&CONST_PI_2,&x);
prt(&x);
NumSinCos(&x,&sn,&cs);
NumScaleTrigVector(&sn,&cs);
prt(&sn);
prt(&cs);
Setting_ErrorOnOverflow = TRUE;
/* NumTan does this anyway */
DECFP_ERR res = NumDivide(&sn,&cs,&tn);
if (res)
printf("ERROR: %s\n",ErrorMessage(res));
else
prt(&tn);
Setting_ErrorOnOverflow = FALSE;
res = NumDivide(&sn,&cs,&tn);
if (res)
printf("ERROR: %s\n",ErrorMessage(res));
else
prt(&tn);
NumNegate(&x,&x);
NumSinCos(&x,&sn,&cs);
NumScaleTrigVector(&sn,&cs);
prt(&sn);
prt(&cs);
Setting_ErrorOnOverflow = TRUE;
res = NumDivide(&sn,&cs,&tn);
if (res)
printf("ERROR: %s\n",ErrorMessage(res));
else
prt(&tn);
Setting_ErrorOnOverflow = FALSE;
res = NumDivide(&sn,&cs,&tn);
if (res)
printf("ERROR: %s\n",ErrorMessage(res));
else
prt(&tn);
return 0;
}
void prt(_NUM* x) {
char* bfr = NumOutFullPrecision(x);
printf("%s\n",bfr);
free(bfr);
}
Gives this output:
Code:
$ bin/decfp
+1.57079632679489661923132e+0000
+1.00000000000000000000000e+0000
+0.00000000000000000000000e+0000
ERROR: Divide by zero
+9.99999999999999999999999e+9999
-1.00000000000000000000000e+0000
+0.00000000000000000000000e+0000
ERROR: Divide by zero
-9.99999999999999999999999e+9999