What is the C# replacement for the following define?
#define IS_FINITE(x) (0x7FF0 != (*((unsigned short*)(&x) + 3) & 0x7FF0))
Maybe double.IsInfinity(x) == false
or double.IsNegativeInfinity(x) == false
?
Thanks.
isFinite is a function property of the global object. You can use this function to determine whether a number is a finite number. The isFinite function examines the number in its argument. If the argument is NaN , positive infinity, or negative infinity, this method returns false ; otherwise, it returns true .
Finite number may refer to: A countable number less than infinity, being the cardinality of a finite set – i.e., some natural number, possibly 0. A real number, such as may result from a measurement (of time, length, area, etc.)
In JavaScript, there are two ways to check if a variable is a number : isNaN() – Stands for “is Not a Number”, if variable is not a number, it return true, else return false. typeof – If variable is a number, it will returns a string named “number”.
!double.IsInfinity(x) && !double.IsNaN(x)
References:
http://pubs.opengroup.org/onlinepubs/009604499/functions/isfinite.html
http://msdn.microsoft.com/en-us/library/system.double.isinfinity.aspx
http://msdn.microsoft.com/en-us/library/system.double.isnan.aspx
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