Example #1
0
        public static MbfSingle FromInt64(long value)
        {
            var single = new MbfSingle(value < 0, (ulong)(Math.Abs(value) << 8), TrueBias + 24);

            single.Normalize();
            return(single);
        }
Example #2
0
        public override MbfSingle ToSingle()
        {
            var bytes   = ToBytes();
            var mantisa = (ulong)Math.Pow((bytes[6] | 0x80) * 0x100, ByteSize - 2);

            // 0, 1
            mantisa  += bytes[4];
            mantisa  += (byte)(bytes[5] * 0x100);
            mantisa <<= 8;

            mantisa += bytes[3];

            var single = new MbfSingle(bytes[6] >= 0x80, mantisa, bytes[7]);

            single.Normalize();
            return(single);
        }