Skip to content
Myr

example7.c

This file

Path

vendor/decNumber/example7.c

35 lines · 1.3 KiB · C

Last changed by

Not known.

History of this file

Take it

The walk stopped after 200 commits: lines older than fa6a2ff point at it.

website: remove unused root path on building website (#3248)itchynybefore adoptionfa6a2ff

lines 1–35why, one step back
1/* ------------------------------------------------------------------ */
2/* Decimal Number Library Demonstration program */ 3/* ------------------------------------------------------------------ */ 4/* Copyright (c) IBM Corporation, 2001, 2008. All rights reserved. */ 5/* ----------------------------------------------------------------+- */ 6/* right margin -->| */ 7 8// example7.c -- using decQuad to add two numbers together 9 10// compile: example7.c decContext.c decQuad.c 11 12#include "decQuad.h" // decQuad library 13#include <stdio.h> // for printf 14 15int main(int argc, char *argv[]) { 16 decQuad a, b; // working decQuads 17 decContext set; // working context 18 char string[DECQUAD_String]; // number->string buffer 19 20 decContextTestEndian(0); // warn if DECLITEND is wrong 21 22 if (argc<3) { // not enough words 23 printf("Please supply two numbers to add.\n"); 24 return 1; 25 } 26 decContextDefault(&set, DEC_INIT_DECQUAD); // initialize 27 28 decQuadFromString(&a, argv[1], &set); 29 decQuadFromString(&b, argv[2], &set); 30 decQuadAdd(&a, &a, &b, &set); // a=a+b 31 decQuadToString(&a, string); 32 33 printf("%s + %s => %s\n", argv[1], argv[2], string); 34 return 0; 35 } // main