On Tuesday, June 24, 2003, at 04:08 AM, Holden Glova wrote:

> [snip]

> I am curious what people use to represent decimals when with no  
> rounding
> error? I have a need for this and have come up against a brick wall. I  
> was
> hoping for something that was similar to BigDecimal in Java - does  
> Ruby have
> anything like this?
> [snip]

See the following:

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF- 
8&selm=5.1.0.14.2.20021210134040.02102738%40zcard04k.ca.nortel.com

There are some other relevant threads, but I couldn't find them.

The most common approach is to do everything in integers with a  
sufficiently large scaling factor and convert to decimal for display  
purposes. The size of the scaling factor depends on the currency your  
working with and the maximum expected amounts. You just figure out  
whether you lose any cents above an amount your program might encounter.

Regards,

Mark Wilson