t_bdSimple.c (original) (raw)

`/* Id:tbdSimple.cId: t_bdSimple.c Id:tbdSimple.c */

/*

/* A very simple test of some "bd" functions */

#include <stdio.h> #include "bigd.h"

int main(void) { BIGD u, v, w;

/* Display the BigDigits version number */
printf("BigDigits version=%d\n", bdVersion());

/* Create new BIGD objects */
/* New way in [v2.6] */
bdNewVars(&u, &v, &w, NULL);

/* Old way - still valid... */
//u = bdNew();
//v = bdNew();
//w = bdNew();

/* Compute 2 * 0xdeadbeefface */
bdSetShort(u, 2);
bdConvFromHex(v, "deadbeefface");
bdMultiply(w, u, v);

/* Display the result */
bdPrintHex("", u, " * ");
bdPrintHex("0x", v, " = ");
bdPrintHex("0x", w, "\n");
/* and again in decimal format */
bdPrintDecimal("", u, " * ");
bdPrintDecimal("", v, " = ");
bdPrintDecimal("", w, "\n");

/* Free all objects we made */
/* New way in [v2.6] */
bdFreeVars(&u, &v, &w, NULL);
/* Old way - still valid... */
//bdFree(&u);
//bdFree(&v);
//bdFree(&w);

return 0;

}`