You could use BigInteger, which was created to work around double's rounding issues - among other things.
(- 12.305M 12.3049M) 0.0001M On 12/10/10 18:17, cej38 wrote: > I keep running into this type of problem: > > user=> (- 12.305 12.3049) > 9.999999999976694E-5 > > The computer (probably the JVM) has just lied to me. Any fourth grade > student will know that this does not equal 0.0001. This would be less > of a problem is the JVM was consistent; if it were consistent then the > following equality would be true: > > user=> (= 0.0001 (- 12.305 12.3049)) > false > > Now it has lied to me again! > > I need a method to reliably compare two numbers. My first choice > would be to have the JVM compute (- 12.305 12.3049) correctly. > Barring that, I need a way to, without fail, compute the truthfulness > of the following: =, <, >, <=, >=. >
signature.asc
Description: OpenPGP digital signature