Re: [q-lang-users] Q 7.2 RC1 Issue 3: IEEE floats
Brought to you by:
agraef
From: John C. <co...@cc...> - 2006-06-19 20:48:01
|
Albert Graef scripsit: > > But none of "on inf", "-inf", or "nan" has the correct meaning input. > > This should be cleaned up. > > I don't understand, what's "on inf"? An editing blunder on my part: it should read: > > But none of "inf", "-inf", or "nan" has the correct meaning on input. > Defining inf and nan as const variables in the library would probably do > the trick. In fact, this is what I do (for inf) in some of my scripts. Indeed. You can define nan as inf - inf. > > This should be cleaned up by defining a syntax for these values to > > be used on input and output, and by not failing when doing a floating > > division by zero (though an exact division by zero should still fail). > > Is there a portable way to check for inf and nan values? (So that I > don't have to rely on the C library to do the right thing when printing > those numbers.) int isinf(double f) { return (f + f == f); } int isnan(double f) { return !(f == f); } These depend on the "stickiness" of infinity and the fact that NaN doesn't compare equal to anything, not even NaN. (Do not simplify to "f != f", as NaN doesn't compare *unequal* to anything either.) -- Values of beeta will give rise to dom! John Cowan (5th/6th edition 'mv' said this if you tried http://www.ccil.org/~cowan to rename '.' or '..' entries; see co...@cc... http://cm.bell-labs.com/cm/cs/who/dmr/odd.html) |