[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ruby-talk
Subject:    Re: when 1.6 != 1.6? -- newbie
From:       Neil Stevens <neil () hakubi ! us>
Date:       2005-04-14 22:24:49
Message-ID: pan.2005.04.14.22.23.27.176690 () hakubi ! us
[Download RAW message or body]

On Fri, 15 Apr 2005 08:11:27 +0900, Ilmari Heikkinen wrote:
> Either do fixed-point decimals with integers and decimal point
> divisor (100 => 1.00*100; 100 + 20 + 20 + 20 - 160 => 0)
> or pick an error threshold and check that (a - b) < threshold
> (1.0 + 0.2 + 0.2 + 0.2 - 1.6) < 0.01
> => true

Just use BigDecimal.  No need to get tricky.
-- 
Neil Stevens - neil@hakubi.us

'A republic, if you can keep it.' -- Benjamin Franklin


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic