1. check for inf/nan [SOLVED]

I recently made a couple of (admitedly a tad silly) tweaks to printf() so that it would print powers of 2 (from -1074 to +1024) perfectly.
Not exactly surprisingly it came a bit of a cropper when presented with +/-inf/nan, so as a "quick fix" I slapped in:

                    and atom_to_float64(o)[$]!=127 -- not [+/-]nan/inf 

which has solved the immediate issue, however I wanted to ask if anyone knows the "proper" way to check.
My attempts at googling this ran me straight into language-specific isnan()-style functions, but I couldn't find the nitty-gritty.
I need something that works with 64 and 80-bit floats.

Also, that (from -1074 to +1024) was lifted straight from an article on dealing with said for 64-bit floats, and
I wouldn't mind knowing what the equivalent limits are for 80-bit floats.

new topic     » topic index » view message » categorize

2. Re: check for inf/nan

Take a look at std/scinot.e at the contents of the scientific_to_float() routine.

new topic     » goto parent     » topic index » view message » categorize

3. Re: check for inf/nan

That was all a bit more effort than anticipated... Took a while to sink in that IEEE 754 does not fully specify NaN, as it says right there on the wikipedia page.
Anyway, Phix has now got proper working builtin is_nan() and is_inf() functions.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu