From: Mark Probert Date: 2002-12-11T03:46:11+09:00 Subject: Re: Proper Type for Dollar Amount At 03:14 AM 12/11/2002 +0900, Bill T. wrote: >Jim Weirich wrote: > > Yes, they were using floating point to represent dollar > > amounts. Never a good idea. > >Well, you can search comp.lang.c about a thread on what type to use >(int/long/double/etc.) to represent dollar amounts (including the >cents). I don't think there is a clear answer that representing dollar >amounts with floating point is a bad idea. It depends on what kinds of >operations you are going to do, which in this case is a division. My own experience (based on developing real-time trading systems for some merchant banks), is that the best solution is to use scaled integers, to 100th of a cent. So, $154.34 --> 1543400. You then get very fast operations (they are all integer operations) and, in general, well with +- 4 billion. Ruby, with BigInt makes it trivial. Regards, -mark.