示例#1
0
        /// <summary>
        /// Convert value represented by type and raw bits to corresponding <seealso cref="NumberValue"/>. If type is not <seealso cref="BYTE"/>, <seealso cref="SHORT"/>,
        /// <seealso cref="INT"/>, <seealso cref="LONG"/>, <seealso cref="FLOAT"/> or <seealso cref="DOUBLE"/>, the raw bits will be interpreted as a long.
        /// </summary>
        /// <param name="rawBits"> Raw bits of value </param>
        /// <param name="type"> Type of value </param>
        /// <returns> <seealso cref="NumberValue"/> with type and value given by provided raw bits and type. </returns>
        internal static NumberValue AsNumberValue(long rawBits, sbyte type)
        {
            switch (type)
            {
            case BYTE:
                return(Values.byteValue(( sbyte )rawBits));

            case SHORT:
                return(Values.shortValue(( short )rawBits));

            case INT:
                return(Values.intValue(( int )rawBits));

            case LONG:
                return(Values.longValue(rawBits));

            case FLOAT:
                return(Values.floatValue(Float.intBitsToFloat(( int )rawBits)));

            case DOUBLE:
                return(Values.doubleValue(Double.longBitsToDouble(rawBits)));

            default:
                // If type is not recognized, interpret as long.
                return(Values.longValue(rawBits));
            }
        }
示例#2
0
 private DoubleValue ReadDouble()
 {
     return(Values.doubleValue(Double.longBitsToDouble(Blocks[_block + 1])));
 }