[Discuss] Financial database / balance?

Richard Pieri richard.pieri at gmail.com
Sat Jan 14 12:43:29 EST 2012


On 1/14/2012 9:44 AM, Jerry Feldman wrote:
> But, Richard Pieri has a very good point about BCD (Binary Coded
> Decimal). The problem with BCD is that it is generally not supported in
> any common microprocessor that I am aware of, but you can use a 64 bit
> int and scale it. Using a 64-bit integer you are not going to lose any
> precision as a LONG_MAX is

Implementing a BCD math library isn't difficult.  It certainly would be 
slower than using native INTs and FLOATs but not devastatingly so.

You can use INTs as Jerry suggests and pretend that decimals don't exist 
except for display purposes.  So, for example, $1,524.79 would be stored 
as 1524790 which gives you three places of decimal precision (mils).

-- 
Rich P.



More information about the Discuss mailing list