Re: Will the following code assert:
- From: "Joe Butler" <ffffh.no.spam@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 23 Nov 2005 00:26:49 -0000
IEEE standard floats have a defined bit pattern. Zero is _defined_ as all
bits off, so your assert would pass without an assertion. This is a +0,
btw. There is also a -0 where the bit pattern is not all zero.
This may or may not be true on platforms that use other floating point
representations.
What _is_ dangerous is to assume that a series of calculations that
mathematically yield a result of zero will be stored as zero in your float.
Your assert will probably fail in these cases.
I'm not sure it testing -0 against 0.0 with an equality test would produce
equality or not....
"Alan Carre" <alan@xxxxxxxxxxxxxxxxx> wrote in message
news:ebQAKK47FHA.252@xxxxxxxxxxxxxxxxxxxxxxx
> // headers...
>
> int main ()
> {
> double d = 0;
> ASSERT (d == 0);
> }
>
> ?
>
> Or is it machine/[HW/SW]floating-point processing dependent? Might
1.0E-1024
> be a convenient way to store zero on some machines? Is there any certainty
> with doubles of floats or do we 100% of the time have to call fabs with
some
> precision spec?
>
>
> Thanks in advance,
> - Alan
>
>
.
- Follow-Ups:
- Re: Will the following code assert:
- From: Igor Tandetnik
- Re: Will the following code assert:
- References:
- Will the following code assert:
- From: Alan Carre
- Will the following code assert:
- Prev by Date: Re: inserting item into list view
- Next by Date: The Qsort
- Previous by thread: Re: Will the following code assert:
- Next by thread: Re: Will the following code assert:
- Index(es):
Relevant Pages
|