Re: Double: 2 Decimal points
- From: "Oliver Wong" <owong@xxxxxxxxxxxxxx>
- Date: Fri, 12 Aug 2005 20:00:01 GMT
"tex" <NoSpam@xxxxxxxxxxx> wrote in message
news:VT5Ie.35$RS.3@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>> One problem I have with this is that (1.0 / 3.0) + (1.0 / 3.0) + (1.0 /
>> 3.0) and ((1.0 + 1.0 + 1.0)/ 3.0) have a result that differs by 10%, and
>> that my experience is that the compiler doesn't always catch that, and
>> that mainframe programmers don't always think about that.
>
> This has nothing to do w/ integer vs floating pt arithmetic, but rather
> the
> problem is that computers, having finite representations of numbers,
> cannot
> do math correctly, PERIOD! (a x b)/c does not always equal a x (b/c)
> on a computer and this is true regardless of number representation or
> compiler.
This isn't strictly true; some computing environments do calculations in
a symbolic manner instead of numerical (e.g. matlab).
If you declare N = 1, D = 3, and X = N/D, it does not store 0.3333...
into X, but actually stores the equation N/D. If you later multiply X by 3,
it will be able to perform the simplification and store X = N, which gives
the correct result.
- Oliver
.
- References:
- Re: Double: 2 Decimal points
- From: Rvde
- Re: Double: 2 Decimal points
- From: tex
- Re: Double: 2 Decimal points
- From: rik
- Re: Double: 2 Decimal points
- From: tex
- Re: Double: 2 Decimal points
- Prev by Date: Re: JDK 1.4.2 download
- Next by Date: Re: public JMenu add(JMenu c)
- Previous by thread: Re: Double: 2 Decimal points
- Next by thread: XML parsing without startelement
- Index(es):
Relevant Pages
|
|