Test for infinity? 
Author Message
 Test for infinity?

Is there any ANSI function or code snippet that would test a double for
(positive) infinity? For that matter, how about for denormals and NaN's?

Please send responses (or copies of posts) to me by email, since I don't
check these newsgroups frequently.

Thank you,
John J. Har



Sun, 09 Aug 1998 03:00:00 GMT  
 Test for infinity?

Quote:
>Is there any ANSI function or code snippet that would test a double for
>(positive) infinity? For that matter, how about for denormals and NaN's?

Take a look at the fp_class_d() and fp_class_f() functions. I don't
know how well they travel across platforms but they are listed under
ANSI/IEEE Std 754-1985 and seem to be present on Suns and SGIs.

[Not ANSI C, and not on any of my platforms, but IEEE is close enough.
 Anyone trying to discuss details of IEEE here will be thrown to
 talk.bizarre. -mod]

Gary



Mon, 10 Aug 1998 03:00:00 GMT  
 Test for infinity?
Quote:

> Is there any ANSI function or code snippet that would test a double for
> (positive) infinity? For that matter, how about for denormals and NaN's?

> Please send responses (or copies of posts) to me by email, since I don't
> check these newsgroups frequently.

John,
As I mentioned in a previous email, I would send something to you.
NaNs, Infinities, and denormals are not included as part of the C
standard. They are covered by other standards, such as IEEE and XPG4
(Unix). IEEE only requires certain properties, such as NaN, Infinity,
and denormals. XPG4 defines the isnan() function, which reports non-zero
when its argument is a NaN. IEEE 754-1985 does recommend function
class(). Digital Unix implements that as fp_class. This function returns
  Constant          Class
  _____________________________________________________
  FP_SNAN           Signaling NaN (Not-a-Number)
  FP_QNAN           Quiet NaN (Not-a-Number)
  FP_POS_INF        +infinity
  FP_NEG_INF        -infinity
  FP_POS_NORM       Positive normalized
  FP_NEG_NORM       Negative normalized
  FP_POS_DENORM     Positive denormalized
  FP_NEG_DENORM     Negative denormalized
  FP_POS_ZERO       +0.0 (positive zero)
  FP_NEG_ZERO       -0.0 (negative zero)

There is also an IEEE finite() function.

Those systems supporting IEEE functionality should have all of these
functions available, though posssibly in some different forms.

--
Jerry Feldman              Digital Unix Development Environment
Digital Equipment Corp.    Nashua, NH 03062-9987      



Sun, 16 Aug 1998 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Test for infinity?

2. Is infinity equal to infinity?

3. test test test test

4. test...test...test

5. nans or infinities as data

6. infinity loop?

7. Infinity and NaNs

8. NAN, +/- Infinity

9. C Float multiplication infinity validation!

10. infinity

11. Infinity

12. Portable Infinity Arithmetic

 

 
Powered by phpBB® Forum Software