vc >> assign NaN, +Inf, -Inf to double/float

Hello everybody,

how can I assign one of the above values to a float or double?

regards,
Andreas

```How do I write Not A Number or +/- infinity (floating point values) as
literal constants (I'm using g++)?

I have a function that returns float, and I need a flag value, and for
various reasons one of NaN, +/-inf would be most convenient.  But how do
I tell my function to return one of these?  The best I can come up with
so far is

float foo()
{
if(bar)
return (2 + 2);
else
return (0.0 / 0.0);
}

Which works, ( (0.0 / 0.0) == NaN, or (1.0 / 0.0) == inf ), but g++
gives me a divide-by-zero warning when I compile.

Regards,
Jon
```

```I have a function to convert Strings to Doubles
double StringToFloat(CString a_test);

some times StringToFloat returns a -1.#IND
for values that can't be converted

This value is supposed to be in a Range.
and sometimes that range is not bounded -1.#INF to 1.#INF

so if I do something Like this, when GetMin() returns -1.#INF and
GetMax() return 1.#INF

double testNum = StringToFloat(strBAdString); //testNum is now -1.#IND

bool tmp = testNum <= m_max;
bool tmp2 = testNum >= GetMin();
bool tmp3 = testNum <= GetMax();
bool tmp4 = testNum == GetMax();
double tmpMax = GetMax();
bool tmp5 = testNum <= tmpMax;

I have a problem that all the tmp bool's are true, except tmp3. tmp3 is
false.

GetMax() is exactly a one line function
that looks like this.
double myClass::GetMax() const
{
return m_max;
}
and m_max is a member function
double m_max;

So my question is Why? Why is tmp3 false?

not only that but shouldn't tmp4 be false. why is it true?

I'm using VC++6 running in Debug mode.

thanks , how
```

```Hi,

I use C# to fill a data field of "float" data type in SQL 2000 server. When
I use Double.NaN value, there seems to be a problem in "Query Analyzer". I
can no longer select the row, an error message: "Numeric value out of
range". However, in Enterprise Manager, I can still see the row with the
"float" data field of value: "-1.#IND".

My question: is this just a bug/flaw in query analyzer, or I am not supposed
to assign Double.NaN to a "float" data type in SQL 2000?

Thanks,
Guogang

```