System.BitConverter.DoubleToInt64Bits C# (CSharp) Метод

DoubleToInt64Bits() публичный статический метод

public static DoubleToInt64Bits ( double value ) : long
value double
Результат long
        public static unsafe long DoubleToInt64Bits(double value) {
            return *((long *)&value);
        }

Usage Example

Пример #1
0
        /// <summary>
        /// Computes a hash code for a double value, using the algorithm from
        /// Joshua Bloch's book <i>Effective Java"</i>
        /// </summary>
        /// <param name="value">A hashcode for the double value</param>
        public static int GetHashCode(double value)
        {
            /*
             * From the java language specification, it says:
             *
             * The value of n>>>s is n right-shifted s bit positions with zero-extension.
             * If n is positive, then the result is the same as that of n>>s; if n is
             * negative, the result is equal to that of the expression (n>>s)+(2<<~s) if
             * the type of the left-hand operand is int
             */
            var f = BitConverter.DoubleToInt64Bits(value);

            //if (f > 0)
            return((int)(f ^ (f >> 32)));
            //return (int) (f ^ ((f >> 32) + (2 << ~32)));
        }
All Usage Examples Of System.BitConverter::DoubleToInt64Bits