TrailingZeros() private static method

private static TrailingZeros ( String s, Int32 index ) : Boolean
s String
index Int32
return Boolean
Exemplo n.º 1
0
        private static unsafe void StringToNumber(string str, NumberStyles options, ref Number.NumberBuffer number, NumberFormatInfo info, bool parseDecimal)
        {
            if (str == null)
            {
                throw new ArgumentNullException("String");
            }
            string str1  = str;
            char * chPtr = (char *)str1;

            if ((IntPtr)chPtr != IntPtr.Zero)
            {
                chPtr += RuntimeHelpers.OffsetToStringData;
            }
            char *str2 = chPtr;

            if (!Number.ParseNumber(ref str2, options, ref number, (StringBuilder)null, info, parseDecimal) || str2 - chPtr < (long)str.Length && !Number.TrailingZeros(str, (int)(str2 - chPtr)))
            {
                throw new FormatException(Environment.GetResourceString("Format_InvalidString"));
            }
            str1 = (string)null;
        }
Exemplo n.º 2
0
        private unsafe static void StringToNumber(string str, NumberStyles options, ref Number.NumberBuffer number, NumberFormatInfo info, bool parseDecimal)
        {
            if (str == null)
            {
                throw new ArgumentNullException("String");
            }

            fixed(string text = str)
            {
                char *ptr = text;

                if (ptr != null)
                {
                    ptr += RuntimeHelpers.OffsetToStringData / 2;
                }
                char *ptr2 = ptr;

                if (!Number.ParseNumber(ref ptr2, options, ref number, null, info, parseDecimal) || ((long)(ptr2 - ptr) < (long)str.Length && !Number.TrailingZeros(str, (int)((long)(ptr2 - ptr)))))
                {
                    throw new FormatException(Environment.GetResourceString("Format_InvalidString"));
                }
            }
        }
Exemplo n.º 3
0
        internal static unsafe bool TryStringToNumber(string str, NumberStyles options, ref Number.NumberBuffer number, StringBuilder sb, NumberFormatInfo numfmt, bool parseDecimal)
        {
            if (str == null)
            {
                return(false);
            }
            string str1  = str;
            char * chPtr = (char *)str1;

            if ((IntPtr)chPtr != IntPtr.Zero)
            {
                chPtr += RuntimeHelpers.OffsetToStringData;
            }
            char *str2 = chPtr;

            if (!Number.ParseNumber(ref str2, options, ref number, sb, numfmt, parseDecimal) || str2 - chPtr < (long)str.Length && !Number.TrailingZeros(str, (int)(str2 - chPtr)))
            {
                return(false);
            }
            str1 = (string)null;
            return(true);
        }
Exemplo n.º 4
0
        internal unsafe static bool TryStringToNumber(string str, NumberStyles options, ref Number.NumberBuffer number, StringBuilder sb, NumberFormatInfo numfmt, bool parseDecimal)
        {
            if (str == null)
            {
                return(false);
            }

            fixed(string text = str)
            {
                char *ptr = text;

                if (ptr != null)
                {
                    ptr += RuntimeHelpers.OffsetToStringData / 2;
                }
                char *ptr2 = ptr;

                if (!Number.ParseNumber(ref ptr2, options, ref number, sb, numfmt, parseDecimal) || ((long)(ptr2 - ptr) < (long)str.Length && !Number.TrailingZeros(str, (int)((long)(ptr2 - ptr)))))
                {
                    return(false);
                }
            }

            return(true);
        }