Fixed point numeric routines.
Henry Spencer
henry at utzoo.uucp
Sun Apr 8 08:38:42 AEST 1990
In article <3804NU013809 at NDSUVM1> NU013809 at NDSUVM1.BITNET (Greg Wettstein) writes:
>I assume that what I need are fixed point numeric routines which will
>handle only a finite number of decimal places of precision. I am hoping
>that someone has some pointers to references describing such routines or
>perhaps a few snippets of C code...
If all amounts are guaranteed to be less than about $20 million, by far
the simplest method is to use `long int' and measure money in pennies.
Just because the input and output have to say `$123.45' doesn't mean you
can't store that internally as the integer `12345'. And the best part is
that `long int' arithmetic is already provided by your compiler.
--
Apollo @ 8yrs: one small step.| Henry Spencer at U of Toronto Zoology
Space station @ 8yrs: .| uunet!attcan!utzoo!henry henry at zoo.toronto.edu
More information about the Comp.lang.c
mailing list