I have some code which returns float::PositiveInfinity to indicate that an event will never happen but for some reason the compiler (MS Visual Studio 2013) gives me the following warning:
warning C4756: overflow in constant arithmetic
The code in question looks like this:
property float MinsRemainingUntilNextEvent
{
virtual float get()
{
return float::PositiveInfinity;
}
}
What does that mean and should I care? MS's documentation didn't explain it for me...
I would bet that the implementors of the compiler chose to emit the warning for any floating-point expression that could be evaluated at compile-time and the result of which was +inf
, meaning that the warning would systematically be emitted for float::PositiveInfinity
.
Your use of float::PositiveInfinity
is completely valid and harmless. Ignore the warning. I would like to recommend you get a better compiler but GCC is similarly silly when it comes to floating-point.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With