Exemplo n.º 1
0
        protected double RequireDouble()
        {
            sb.Clear();
            var  ch  = SkipSpaces();
            bool neg = ch == '-';

            if (neg)
            {
                sb.Append(ch);
                ch = Reader.ReadChar();
            }
            if (ch == 'N')
            {
                Require("aN");
                return(double.NaN);
            }
            if (ch == 'I')
            {
                Require("nfinity");
                return(neg ? double.NegativeInfinity : double.PositiveInfinity);
            }
            ch = JsonNumberReader.ReadUnsignedFloat(Reader, sb, ch);
            PutBack(ch);
            return(double.Parse(sb.ToString(), CultureInfo.InvariantCulture));
        }
Exemplo n.º 2
0
        protected decimal RequireDecimal()
        {
            sb.Clear();
            var  ch  = SkipSpaces();
            bool neg = ch == '-';

            if (neg)
            {
                sb.Append(ch);
                ch = Reader.ReadChar();
            }
            ch = JsonNumberReader.ReadUnsignedFloat(Reader, sb, ch);
            PutBack(ch);
            return(decimal.Parse(sb.ToString(), CultureInfo.InvariantCulture));
        }