Re: 0.06 == 0.06 returns false in Ruby?
- From: Ken Bloom <kbloom@xxxxxxxxx>
- Date: Fri, 31 Aug 2007 11:01:59 -0500
On Sat, 01 Sep 2007 00:24:39 +0900, M. Edward (Ed) Borasky wrote:
Kyle Schmitt wrote:
On 8/30/07, doug meyer <doug.meyer@xxxxxxxxxx> wrote:IIRC BigDecimal is in fact stored in (pregnant pause) Binary Coded
There is also a class called BigDecimal (or something like that) if
you want to have really accurate numbers and no floating-point errors.
A warning on things like BigDecimal.
Unless I'm mistaken it's still stored in twos compliment, which means
you'll still end up with the same sort of floating point problems
(albeit further down), and the same numbers that you can't express
exactly with a normal float, can't be expressed exactly with a
BigDecimal.
You'd think some fixed point math libraries would help, but be careful,
because many of those _also_ store in twos compliment.
--Kyle
Decimal. But I should check that.
Neither one can represent 1/3 or sqrt(2) exactly.
--
Ken Bloom. PhD candidate. Linguistic Cognition Laboratory.
Department of Computer Science. Illinois Institute of Technology.
http://www.iit.edu/~kbloom1/
.
- Follow-Ups:
- Re: 0.06 == 0.06 returns false in Ruby?
- From: M. Edward (Ed) Borasky
- Re: 0.06 == 0.06 returns false in Ruby?
- References:
- 0.06 == 0.06 returns false in Ruby?
- From: Jason G.
- Re: 0.06 == 0.06 returns false in Ruby?
- From: Dan Zwell
- Re: 0.06 == 0.06 returns false in Ruby?
- From: Dan Zwell
- Re: 0.06 == 0.06 returns false in Ruby?
- From: doug meyer
- Re: 0.06 == 0.06 returns false in Ruby?
- From: M. Edward (Ed) Borasky
- 0.06 == 0.06 returns false in Ruby?
- Prev by Date: Re: 0.06 == 0.06 returns false in Ruby?
- Next by Date: Re: ENV['LD_LIBRARY_PATH'] not changing env
- Previous by thread: Re: 0.06 == 0.06 returns false in Ruby?
- Next by thread: Re: 0.06 == 0.06 returns false in Ruby?
- Index(es):