Exemple #1
0
        internal static CBORObject ParseSmallNumber(int digit, JSONOptions
                                                    options)
        {
      #if DEBUG
            if (digit < 0)
            {
                throw new ArgumentException("digit (" + digit + ") is not greater" +
                                            "\u0020or equal to 0");
            }
      #endif

            if (options != null && options.NumberConversion ==
                JSONOptions.ConversionMode.Double)
            {
                return(CBORObject.FromFloatingPointBits(
                           CBORUtilities.IntegerToDoubleBits(digit),
                           8));
            }
            else if (options != null && options.NumberConversion ==
                     JSONOptions.ConversionMode.Decimal128)
            {
                return(CBORObject.FromObject(EDecimal.FromInt32(digit)));
            }
            else
            {
                // NOTE: Assumes digit is nonnegative, so PreserveNegativeZeros is irrelevant
                return(CBORObject.FromObject(digit));
            }
        }