|
-
December 19th, 2007, 05:41 PM
#1
numeric_limits question
I was wondering what the equivalent to
Code:
numeric_limits<double>::infinity()
numeric_limits<double>::quiet_NaN()
numeric_limits<double>::signaling_NaN()
would be in C.
I have tried
Code:
#include <float.h>
isinf (DBL_MAX + 1)
and many other variants with no success.
I would also rather use a macro or a function rather than doing something
like
Code:
isinf (exp (100000))
Regards,
crei
-
December 19th, 2007, 06:14 PM
#2
Re: numeric_limits question
Try to add the include <math.h>
From MSDN:
Code:
DBL_MAX 1.7976931348623158e+308 Maximum value
-
December 19th, 2007, 06:29 PM
#3
Re: numeric_limits question
But this could vary from compiler to compiler. I need a function or macro. Also what about Nan?
-
December 20th, 2007, 05:13 PM
#4
Re: numeric_limits question
Just to answer my own question just incase anyone else faces this problem:
In gcc there are INFINITY and NAN defines in math.h. However you need to compile the source with gcc -std::c99. Windows has there own macros. You can find them in float.h
-
December 21st, 2007, 04:52 AM
#5
Re: numeric_limits question
The double type follows the IEEE 754 standard, please look it up at wikipedia. Certain bit combinations don´t represent a valid double, instead they´re used to code special cases like NaN, positive infinity and the like. When your compiler does not support these cases you can define them by your own by providing the according bit combinations.
- Guido
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|