t_bdSimple.c (original) (raw)
`/* Id:tbdSimple.cId: t_bdSimple.c Id:tbdSimple.c */
/*
- Copyright (C) 2001-26 David Ireland, D.I. Management Services Pty Limited
- https://di-mgt.com.au/contact/ https://di-mgt.com.au/bigdigits.html
- SPDX-License-Identifier: MPL-2.0
- Last updated:
- Date:2026−03−2908:07:00Date: 2026-03-29 08:07:00 Date:2026−03−2908:07:00
- Revision:2.7.0Revision: 2.7.0 Revision:2.7.0
- Author:daiAuthor: dai Author:dai */
/* 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;}`