From: "trans. (T. Onoma)" Date: 2004-10-28T06:06:37+09:00 Subject: Re: Rounding error, (100.0 * 9.95).to_i == 994 On Wednesday 27 October 2004 04:57 pm, Jamis Buck wrote: | trans. (T. Onoma) wrote: | > On Wednesday 27 October 2004 04:36 pm, Hal Fulton wrote: | > | Jason DiCioccio wrote: | > | > I'm confused now.. 100.0 * 9.95 is clearly 995. So what exactly is | > | > the issue with floating point numbers is making this come out to | > | > 994.999999999983 (or wahtever ;))? If every language is plagued by | > | > this problem, then I'd be curious to know the history behind it.. | > | > | > | :) It's not history, it's math. | > | | > | Here's the short explanation. | > | | > | Remember repeating decimals, which you learned about in elementary | > | school? For example, 1/3 = 0.33333... can't be expressed in a finite | > | number of digits. | > | > Not exactly, '1/3' is finite. | | ... That's not what I learned in school. How many decimal digits does it | take to express 1/3, then? One, if you put a line over it --that's my point, any rational can be represented in a finite amount of space. T.