develooper Front page | perl.perl5.porters | Postings from February 2001

Re: IV preservation (was Re: [PATCH 5.7.0] compiling on OS/2)

Thread Previous | Thread Next
From:
nick
Date:
February 16, 2001 13:32
Subject:
Re: IV preservation (was Re: [PATCH 5.7.0] compiling on OS/2)
Message ID:
E14TsQa-0004H1-00@roam1
Ilya Zakharevich <ilya@math.ohio-state.edu> writes:
>
>Do you know what IEEE says about such checks?  

I think so (or I can go look)...

>Is -0 an integer?  

Yes 0.

(Though ±0 is an area if IEEE floats that makes me sick...)

>Is
>-Inf?  

No, (and it is out of range anyway...)

>Is NaN?  

No. It isn't a number, so how can it be an integer.

>Etc etc etc.  Checking that a float is an integer is
>a non-trivial and a very expensive operation.

No it isn't (at least for IEEE). It is a simple matter of comparing 
the (binary) exponent with the (known, constant) number of bits in the mantissa.
and then seeing if there are any non-zero bits to the right of the radix point.
(am I missing something here?).
Non-coincidentally the special exponent values for Inf and NaN are outside 
that range.

There are usually macros to do that. 

What is much harder to do is the same thing from portable C code.

-- 
Nick Ing-Simmons


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About