public static double Abs(double value) { const ulong mask = 0x7FFFFFFFFFFFFFFF; ulong raw = BitConverter.DoubleToUInt64Bits(value); return(BitConverter.UInt64BitsToDouble(raw & mask)); }
// // Native Declarations // //| <include path='docs/doc[@for="Double.IsInfinity"]/*' /> public static bool IsInfinity(double d) { ulong v = BitConverter.DoubleToUInt64Bits(d); return(v == PositiveInfinityAsUInt64 || v == NegativeInfinityAsUInt64); }
//| <include path='docs/doc[@for="Double.IsNaN"]/*' /> public static bool IsNaN(double d) { // See also Lightning\Src\ClassLibNative\Float\COMFloat::IsNAN ulong v = BitConverter.DoubleToUInt64Bits(d); return(((v & PositiveInfinityAsUInt64) == v) && ((v & MantissaAsUInt64) != 0)); }
static bool IBinaryNumber <double> .IsPow2(double value) { ulong bits = BitConverter.DoubleToUInt64Bits(value); uint exponent = (uint)(bits >> ExponentShift) & ShiftedExponentMask; ulong significand = bits & SignificandMask; return((value > 0) && (exponent != MinExponent) && (exponent != MaxExponent) && (significand == MinSignificand)); }
// // IBinaryNumber // /// <inheritdoc cref="IBinaryNumber{TSelf}.IsPow2(TSelf)" /> public static bool IsPow2(double value) { ulong bits = BitConverter.DoubleToUInt64Bits(value); ushort biasedExponent = ExtractBiasedExponentFromBits(bits);; ulong trailingSignificand = ExtractTrailingSignificandFromBits(bits); return((value > 0) && (biasedExponent != MinBiasedExponent) && (biasedExponent != MaxBiasedExponent) && (trailingSignificand == MinTrailingSignificand)); }
static double IBitwiseOperators <double, double, double> .operator ~(double value) { ulong bits = ~BitConverter.DoubleToUInt64Bits(value); return(BitConverter.UInt64BitsToDouble(bits)); }
static double IBitwiseOperators <double, double, double> .operator ^(double left, double right) { ulong bits = BitConverter.DoubleToUInt64Bits(left) ^ BitConverter.DoubleToUInt64Bits(right); return(BitConverter.UInt64BitsToDouble(bits)); }
//The hashcode for a double is the absolute value of the integer representation //of that double. // //| <include path='docs/doc[@for="Double.GetHashCode"]/*' /> public override int GetHashCode() { long value = unchecked ((long)BitConverter.DoubleToUInt64Bits(m_value)); return(((int)value) ^ ((int)(value >> 32))); }