Method IsEvenInteger
IsEvenInteger(double)
Returns true when the provided double represents an integer with no fractional part and that integer is even. NaN and Infinity return false. Uses the 2^53 shortcut: all representable double integers with absolute value >= 2^53 have spacing >= 2, so any such representable integer is even.
public static bool IsEvenInteger(double value)
Parameters
valuedoubleThe value to evaluate.
Returns
- bool
trueifvalueis an integer and divisible by 2; otherwise,false.
Examples
IsEvenInteger(4.0) // returns true
IsEvenInteger(3.0) // returns false
IsEvenInteger(2.5) // returns false
IsEvenInteger(-6.0) // returns true
IsEvenInteger(0.0) // returns true
IsEvenInteger(float)
Determines whether a single-precision floating-point value represents an even integer.
public static bool IsEvenInteger(float value)
Parameters
valuefloatThe value to evaluate.
Returns
- bool
trueifvalueis an integer and divisible by 2; otherwise,false.
Examples
IsEven(4f); // returns true
IsEven(3f); // returns false
IsEven(2.5f); // returns false
IsEven(-6f); // returns true
IsEven(0f); // returns true