Re: Will the following code assert:

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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
>
>


.



Relevant Pages

  • Re: Pattern to the primes
    ... So the zero set for this function is ... Again, I understand that it can't be the pattern, because my training ... essentially "random" distribution of prime numbers. ...
    (sci.math)
  • Re: any() and all() on empty list?
    ... This is trivially true in the case of the empty list. ... def any: ... zero = any ... assert == one ...
    (comp.lang.python)
  • Re: Ruby 1.8 vs 1.9
    ... You run into this issue once you leave the defined space for IEEE ... Floats, ... But then we have the problem of the required CPU time ... something which is close to zero. ...
    (comp.lang.ruby)
  • Re: Regex Question
    ... Which says that the Day named group needs to be zero or one of MON, TUE, ... > min item# day date time number callto ratecode ratepd feature airchg ... > So i was wondering if anyone knew of a way that i could make a pattern ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Regex help
    ... regex in my code snip wasn't working as it did on the text snippet I originally supplied. ... I can understand the 2nd method: A grouped, literal comma, one or more times followed by a zero or more spaces. ... follow the pattern but is not included as part of the pattern. ...
    (perl.beginners)