# C - Infinity



## mt2002 (Sep 14, 2005)

Hello everyone,

I am needing to define the value for infinity in my MSVC++ 2008 RTL. However I cannot seem to be able to obtain the value for it nor define it:


```
#define INFINITY (1.0/0.0)
/*const*/ double _infinity = INFINITY;
```
This produces *error C2099: initializer is not a constant* which itself does not make sense considering 1.0/0.0 is, technically, a constant expression.

Does anyone know how I can define infinity in MSVC?

Thanks for any help


----------



## IMM (Feb 1, 2002)

There is a fcn for determining finite
http://msdn.microsoft.com/en-us/library/aa246875(VS.60).aspx
I think it reacts to the already defined +INF, -INF and NaN returns
Have a look through float.h

There's also fpclass in float.h
http://www.johndcook.com/IEEE_exceptions_in_cpp.html


----------

