Re: double with precision
- From: "Daniel Dyer" <"You don't need it">
- Date: Thu, 28 Jun 2007 00:35:51 +0100
On Wed, 27 Jun 2007 23:25:16 +0100, Roy Gourgi <royng@xxxxxxxxxxxx> wrote:
Thanks Eric,
Just out of curiosity why can't the number 1.74 be represented exactly with
a double?
http://www2.hursley.ibm.com/decimal/decifaq1.html#inexact
The solution, in Java, is to use BigDecimal (http://java.sun.com/j2se/1.5.0/docs/api/java/math/BigDecimal.html) instead of double, but that can make your code quite clunky. An alternative is to multiply all of your values by 100 so that you are never dealing with fractions (except when you convert them for display).
Dan.
--
Daniel Dyer
http//www.uncommons.org
.
- References:
- double with precision
- From: Roy Gourgi
- Re: double with precision
- From: Roy Gourgi
- double with precision
- Prev by Date: Re: double with precision
- Next by Date: Sort Method Conversion
- Previous by thread: Re: double with precision
- Next by thread: Re: double with precision
- Index(es):
Relevant Pages
|