Xref: utzoo comp.lang.c:27647 comp.sources.wanted:11315 Newsgroups: comp.lang.c,comp.sources.wanted Path: utzoo!henry From: henry@utzoo.uucp (Henry Spencer) Subject: Re: Fixed point numeric routines. Message-ID: <1990Apr7.223842.14425@utzoo.uucp> Organization: U of Toronto Zoology References: <3804NU013809@NDSUVM1> Date: Sat, 7 Apr 90 22:38:42 GMT In article <3804NU013809@NDSUVM1> NU013809@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@zoo.toronto.edu