Exemple #1
0
 public JsonNumber(JsonNumberType type, double value, long value_int64, ulong value_uint64)
 {
     _type = type;
     _value = value;
     if (type == JsonNumberType.Signed) {
         _value_i64 = value_int64;
     } else if (type == JsonNumberType.Unsigned) {
         _value_ui64 = value_uint64;
     }
 }
Exemple #2
0
 public JsonNumber(JsonNumberType type, double value, long value_int64, ulong value_uint64)
 {
     _type  = type;
     _value = value;
     if (type == JsonNumberType.Signed)
     {
         _value_i64 = value_int64;
     }
     else if (type == JsonNumberType.Unsigned)
     {
         _value_ui64 = value_uint64;
     }
 }
Exemple #3
0
        private void ProcessNumber(string number)
        {
            token = JsonToken.Number;

            long n_long;

            if (long.TryParse(number, out n_long))
            {
                number_type   = JsonNumberType.SignedInteger;
                number_signed = n_long;
                token_value   = (double)n_long;
                return;
            }

            ulong n_ulong;

            if (ulong.TryParse(number, out n_ulong))
            {
                number_type     = JsonNumberType.UnsignedInteger;
                number_unsigned = n_ulong;
                token_value     = (double)n_ulong;
                return;
            }

            double n_double;

            if (Double.TryParse(number, out n_double))
            {
                number_type = JsonNumberType.FloatingPoint;
                token_value = n_double;
                return;
            }

            // Shouldn't happen, but just in case, return something
            number_type = JsonNumberType.FloatingPoint;
            token_value = 0.0;
        }
Exemple #4
0
        private void ProcessNumber(string number)
        {
            token = JsonToken.Number;

            long n_long;
            if (long.TryParse (number, out n_long)) {
                number_type = JsonNumberType.SignedInteger;
                number_signed = n_long;
                token_value = (double)n_long;
                return;
            }

            ulong n_ulong;
            if (ulong.TryParse (number, out n_ulong)) {
                number_type = JsonNumberType.UnsignedInteger;
                number_unsigned = n_ulong;
                token_value = (double)n_ulong;
                return;
            }

            double n_double;
            if (Double.TryParse (number, out n_double)) {
                number_type = JsonNumberType.FloatingPoint;
                token_value = n_double;
                return;
            }

            // Shouldn't happen, but just in case, return something
            number_type = JsonNumberType.FloatingPoint;
            token_value = 0.0;
        }