// The standard CLR double.IsNaN() function is approximately 100 times slower than our own wrapper, // so please make sure to use DoubleUtil.IsNaN() in performance sensitive code. // PS item that tracks the CLR improvement is DevDiv Schedule : 26916. // IEEE 754 : If the argument is any value in the range 0x7ff0000000000001L through 0x7fffffffffffffffL // or in the range 0xfff0000000000001L through 0xffffffffffffffffL, the result will be NaN. public static bool IsNaN(double value) { NanUnion t = new NanUnion(); t.DoubleValue = value; UInt64 exp = t.UintValue & 0xfff0000000000000; UInt64 man = t.UintValue & 0x000fffffffffffff; return((exp == 0x7ff0000000000000 || exp == 0xfff0000000000000) && (man != 0)); }
public static bool IsNaN(double value) { var t = new NanUnion { DoubleValue = value }; var exp = t.UintValue & 0xfff0000000000000; var man = t.UintValue & 0x000fffffffffffff; return((exp == 0x7ff0000000000000 || exp == 0xfff0000000000000) && (man != 0)); }
public static bool IsNaN(double value) { var t = new NanUnion { DoubleValue = value }; var exp = t.UlongValue & 0xfff0000000000000; var man = t.UlongValue & 0x000fffffffffffff; return(exp is 0x7ff0000000000000 or 0xfff0000000000000 && man != 0); }
public static bool IsNaN(double value) { NanUnion nanUnion = default(NanUnion); nanUnion.DoubleValue = value; ulong num = nanUnion.UintValue & 18442240474082181120uL; ulong num2 = nanUnion.UintValue & 4503599627370495uL; return((num == 9218868437227405312uL || num == 18442240474082181120uL) && num2 != 0uL); }
// The standard CLR double.IsNaN() function is approximately 100 times slower than our own wrapper, // so please make sure to use DoubleUtil.IsNaN() in performance sensitive code. // PS item that tracks the CLR improvement is DevDiv Schedule : 26916. // IEEE 754 : If the argument is any value in the range 0x7ff0000000000001L through 0x7fffffffffffffffL // or in the range 0xfff0000000000001L through 0xffffffffffffffffL, the result will be NaN. public static bool IsNaN(double value) { var t = new NanUnion(); t.DoubleValue = value; ulong exp = t.UintValue & 0xfff0000000000000; ulong man = t.UintValue & 0x000fffffffffffff; return((exp == 0x7ff0000000000000 || exp == 0xfff0000000000000) && (man != 0)); }
/// <summary> /// Gets whether value is not an number. /// </summary> /// <param name="value">value to test</param> /// <returns>true if value is not an number</returns> public static bool IsNaN(double value) { NanUnion union = new NanUnion(); union.DoubleValue = value; ulong num = union.UintValue & 18442240474082181120L; ulong num2 = union.UintValue & ((ulong)0xfffffffffffffL); if ((num != 0x7ff0000000000000L) && (num != 18442240474082181120L)) { return false; } return (num2 != 0L); }
/// <summary> /// Indicates whether the value is not a number. /// </summary> public static bool IsNaN(double value) { NanUnion t = new NanUnion { DoubleValue = value }; ulong exp = t.UintValue & 0xfff0000000000000; ulong man = t.UintValue & 0x000fffffffffffff; return((exp == 0x7ff0000000000000 || exp == 0xfff0000000000000) && man != 0); }
public static bool IsNaN( double value ) { // used reflector to borrow the high performance IsNan function // from the WPF MS.Internal namespace NanUnion t = new NanUnion(); t.DoubleValue = value; UInt64 exp = t.UintValue & 0xfff0000000000000; UInt64 man = t.UintValue & 0x000fffffffffffff; return ( exp == 0x7ff0000000000000 || exp == 0xfff0000000000000 ) && ( man != 0 ); }
public static bool IsNaN(double value) { // used reflector to borrow the high performance IsNan function // from the WPF MS.Internal namespace NanUnion t = new NanUnion(); t.DoubleValue = value; UInt64 exp = t.UintValue & 0xfff0000000000000; UInt64 man = t.UintValue & 0x000fffffffffffff; return((exp == 0x7ff0000000000000 || exp == 0xfff0000000000000) && (man != 0)); }
public static bool IsNaN(double value) { NanUnion union = new NanUnion(); union.DoubleValue = value; ulong num = union.UintValue & 18442240474082181120L; ulong num2 = union.UintValue & ((ulong)0xfffffffffffffL); if ((num != 0x7ff0000000000000L) && (num != 18442240474082181120L)) { return(false); } return(num2 != 0L); }
public static bool IsNaN(double value) { NanUnion nanUnion = new NanUnion(); nanUnion.DoubleValue = value; ulong num1 = nanUnion.UintValue & 18442240474082181120UL; ulong num2 = nanUnion.UintValue & 4503599627370495UL; if ((long)num1 == 9218868437227405312L || (long)num1 == -4503599627370496L) { return(num2 > 0UL); } return(false); }
public static bool IsNaN(double value) { NanUnion nanUnion = default(NanUnion); nanUnion.DoubleValue = value; ulong num = (ulong)((long)nanUnion.UintValue & -4503599627370496L); ulong num2 = nanUnion.UintValue & 0xFFFFFFFFFFFFF; if (num == 9218868437227405312L || num == 18442240474082181120uL) { return(num2 != 0); } return(false); }
/// <summary> /// Check if a number isn't really a number. /// </summary> /// <param name="value">The number to check.</param> /// <returns> /// True if the number is not a number, false if it is a number. /// </returns> public static bool IsNaN(this double value) { // Get the double as an unsigned long NanUnion union = new NanUnion { FloatingValue = value }; // An IEEE 754 double precision floating point number is NaN if its // exponent equals 2047 and it has a non-zero mantissa. ulong exponent = union.IntegerValue & 0xfff0000000000000L; if ((exponent != 0x7ff0000000000000L) && (exponent != 0xfff0000000000000L)) { return false; } ulong mantissa = union.IntegerValue & 0x000fffffffffffffL; return mantissa != 0L; }
internal static bool IsNaN(double value) { var union = new NanUnion { DoubleValue = value }; ulong num = union.UintValue & 18442240474082181120L; ulong num2 = union.UintValue & (0xfffffffffffffL); if ((num != 0x7ff0000000000000L) && (num != 18442240474082181120L)) { return(false); } return(num2 != 0L); }
/// <summary> /// Check if a number isn't really a number. /// </summary> /// <param name="value">The number to check.</param> /// <returns> /// True if the number is not a number, false if it is a number. /// </returns> public static bool IsNaN(this double value) { // Get the double as an unsigned long NanUnion union = new NanUnion {FloatingValue = value}; // An IEEE 754 double precision floating point number is NaN if its // exponent equals 2047 and it has a non-zero mantissa. ulong exponent = union.IntegerValue & 0xfff0000000000000L; if ((exponent != 0x7ff0000000000000L) && (exponent != 0xfff0000000000000L)) { return false; } ulong mantissa = union.IntegerValue & 0x000fffffffffffffL; return mantissa != 0L; }
public static bool IsNaN(this double value) { var nanUnion = new NanUnion { FloatingValue = value }; var num = nanUnion.IntegerValue & 18442240474082181120uL; bool result; if (num != 9218868437227405312uL && num != 18442240474082181120uL) { result = false; } else { var num2 = nanUnion.IntegerValue & 4503599627370495uL; result = (num2 != 0uL); } return(result); }
/// <summary> /// Indicates whether the value is not a number. /// </summary> public static bool IsNaN(double value) { NanUnion t = new NanUnion(); t.DoubleValue = value; UInt64 exp = t.UintValue & 0xfff0000000000000; UInt64 man = t.UintValue & 0x000fffffffffffff; return (exp == 0x7ff0000000000000 || exp == 0xfff0000000000000) && (man != 0); }
/// <summary> /// Faster check for NaN ( faster than double.IsNaN() ) /// IEEE 754 : If the argument is any value in the range 0x7ff0000000000001L through 0x7fffffffffffffffL /// or in the range 0xfff0000000000001L through 0xffffffffffffffffL, the result will be NaN. /// </summary> /// <param name="value">Value to check</param> /// <returns></returns> public static bool IsNaN(double value) { var t = new NanUnion { DoubleValue = value }; var exp = t.UintValue & 0xfff0000000000000; var man = t.UintValue & 0x000fffffffffffff; return (exp == 0x7ff0000000000000 || exp == 0xfff0000000000000) && (man != 0); }