public static AmountValue FromParser(BinaryParser parser)
        {
            AmountValue value;
            var         mantissa = parser.Read(8);
            var         b1       = mantissa[0];
            var         b2       = mantissa[1];

            var isIou      = (b1 & 0x80) != 0;
            var isPositive = (b1 & 0x40) != 0;
            var sign       = isPositive ? 1 : -1;

            if (isIou)
            {
                mantissa[0] = 0;
                var exponent = ((b1 & 0x3F) << 2) + ((b2 & 0xff) >> 6) - 97;
                mantissa[1] &= 0x3F;
                value        = new IouValue(mantissa, sign, exponent);
            }
            else
            {
                mantissa[0] &= 0x3F;
                value        = new NativeValue(mantissa, sign);
            }
            return(value);
        }
Example #2
0
        public static AmountValue FromParser(BinaryParser parser)
        {
            AmountValue value;
            var mantissa = parser.Read(8);
            var b1 = mantissa[0];
            var b2 = mantissa[1];

            var isIou = (b1 & 0x80) != 0;
            var isPositive = (b1 & 0x40) != 0;
            var sign = isPositive ? 1 : -1;

            if (isIou)
            {
                mantissa[0] = 0;
                var exponent = ((b1 & 0x3F) << 2) + ((b2 & 0xff) >> 6) - 97;
                mantissa[1] &= 0x3F;
                value = new IouValue(mantissa, sign, exponent);
            }
            else
            {
                mantissa[0] &= 0x3F;
                value = new NativeValue(mantissa, sign);
            }
            return value;
        }
 public static AmountValue FromString(string value, bool native = false)
 {
     if (native)
     {
         return(new NativeValue(value));
     }
     return(IouValue.FromString(value));
 }