Re: This calculation is just wrong / computer can't count!
- From: Geoff <geoff@xxxxxxxxxxxxxxx>
- Date: Sun, 07 Oct 2007 04:44:45 GMT
On Thu, 4 Oct 2007 22:44:14 +0100, "GT"
<ContactGT_remove_@xxxxxxxxxxx> wrote:
One of the results should be exactly 0, but the computer gives the
result -0.00000000007. Which is then displayed on the screen as -0.0. This
result is displayed on the screen (in an edit boxes) along with all the
positive numbers and is just wrong!
-0.0 = 0.0 for all intents and purposes. The only difference is the
sign bit in the internal representation.
You cannot perform floating point math on a computer and compare the
result to integer 0 or even a float 0. You must compare it to what
your application will allow to be close enough to zero to be
considered zero. Therefore your statements for comparing a floating
point value to zero to six figures should be the equivalent of:
If 0.000001 > n < -0.000001 then n = 0 where n is type double and the
bracketing values are acceptable in your application.
.
- References:
- This calculation is just wrong / computer can't count!
- From: GT
- Re: This calculation is just wrong / computer can't count!
- From: AliR \(VC++ MVP\)
- Re: This calculation is just wrong / computer can't count!
- From: GT
- Re: This calculation is just wrong / computer can't count!
- From: Luke alcatel
- Re: This calculation is just wrong / computer can't count!
- From: GT
- This calculation is just wrong / computer can't count!
- Prev by Date: Re: This calculation is just wrong / computer can't count!
- Next by Date: Re: This calculation is just wrong / computer can't count!
- Previous by thread: Re: This calculation is just wrong / computer can't count!
- Next by thread: Re: This calculation is just wrong / computer can't count!
- Index(es):
Relevant Pages
|