NumberToInt64() private static method

private static NumberToInt64 ( NumberBuffer &number, Int64 &value ) : Boolean
number NumberBuffer
value Int64
return Boolean
Example #1
0
        internal static unsafe long ParseInt64(string value, NumberStyles options, NumberFormatInfo numfmt)
        {
            byte *stackBuffer = stackalloc byte[Number.NumberBuffer.NumberBufferBytes];

            Number.NumberBuffer number = new Number.NumberBuffer(stackBuffer);
            long num = 0;

            Number.StringToNumber(value, options, ref number, numfmt, false);
            if ((options & NumberStyles.AllowHexSpecifier) != NumberStyles.None)
            {
                if (!Number.HexNumberToInt64(ref number, ref num))
                {
                    throw new OverflowException(Environment.GetResourceString("Overflow_Int64"));
                }
            }
            else if (!Number.NumberToInt64(ref number, ref num))
            {
                throw new OverflowException(Environment.GetResourceString("Overflow_Int64"));
            }
            return(num);
        }
        internal unsafe static long ParseInt64(string value, NumberStyles options, NumberFormatInfo numfmt)
        {
            byte *stackBuffer = stackalloc byte[checked (unchecked ((UIntPtr)Number.NumberBuffer.NumberBufferBytes) * 1)];

            Number.NumberBuffer numberBuffer = new Number.NumberBuffer(stackBuffer);
            long result = 0L;

            Number.StringToNumber(value, options, ref numberBuffer, numfmt, false);
            if ((options & NumberStyles.AllowHexSpecifier) != NumberStyles.None)
            {
                if (!Number.HexNumberToInt64(ref numberBuffer, ref result))
                {
                    throw new OverflowException(Environment.GetResourceString("Overflow_Int64"));
                }
            }
            else if (!Number.NumberToInt64(ref numberBuffer, ref result))
            {
                throw new OverflowException(Environment.GetResourceString("Overflow_Int64"));
            }
            return(result);
        }
Example #3
0
        internal static unsafe bool TryParseInt64(string s, NumberStyles style, NumberFormatInfo info, out long result)
        {
            byte *stackBuffer = stackalloc byte[Number.NumberBuffer.NumberBufferBytes];

            Number.NumberBuffer number = new Number.NumberBuffer(stackBuffer);
            result = 0L;
            if (!Number.TryStringToNumber(s, style, ref number, info, false))
            {
                return(false);
            }
            if ((style & NumberStyles.AllowHexSpecifier) != NumberStyles.None)
            {
                if (!Number.HexNumberToInt64(ref number, ref result))
                {
                    return(false);
                }
            }
            else if (!Number.NumberToInt64(ref number, ref result))
            {
                return(false);
            }
            return(true);
        }