Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ StringToDouble()

static unsafe double System.Xml.Xsl.XPathConvert.StringToDouble ( string s)
inlinestatic

Definition at line 1828 of file XPathConvert.cs.

1829 {
1830 fixed (char* ptr = s)
1831 {
1832 int num = 0;
1833 char* ptr2 = ptr;
1834 char* ptr3 = null;
1835 int num2 = 1;
1836 int num3 = 0;
1837 while (true)
1838 {
1839 char c = *(ptr2++);
1840 if (!IsAsciiDigit(c))
1841 {
1842 if (c != '-')
1843 {
1844 if (c == '.')
1845 {
1846 if (IsAsciiDigit(*ptr2))
1847 {
1848 goto IL_00b8;
1849 }
1850 }
1851 else if (IsWhitespace(c) && num2 > 0)
1852 {
1854 continue;
1855 }
1856 }
1857 else if (num2 >= 0)
1858 {
1859 num2 = -1;
1860 continue;
1861 }
1862 return double.NaN;
1863 }
1864 if (c == '0')
1865 {
1866 do
1867 {
1868 c = *(ptr2++);
1869 }
1870 while (c == '0');
1871 if (!IsAsciiDigit(c))
1872 {
1873 goto IL_00b2;
1874 }
1875 }
1876 ptr3 = ptr2 - 1;
1877 do
1878 {
1879 c = *(ptr2++);
1880 }
1881 while (IsAsciiDigit(c));
1882 num = (int)(ptr2 - ptr3) - 1;
1883 goto IL_00b2;
1884 IL_00b8:
1885 c = *(ptr2++);
1886 if (ptr3 == null)
1887 {
1888 while (c == '0')
1889 {
1890 num3--;
1891 c = *(ptr2++);
1892 }
1893 ptr3 = ptr2 - 1;
1894 }
1895 while (IsAsciiDigit(c))
1896 {
1897 num3--;
1898 num++;
1899 c = *(ptr2++);
1900 }
1901 break;
1902 IL_00b2:
1903 if (c != '.')
1904 {
1905 break;
1906 }
1907 goto IL_00b8;
1908 }
1909 ptr2--;
1910 char* ptr4 = ptr + s.Length;
1911 if (ptr2 < ptr4 && SkipWhitespace(ptr2) < ptr4)
1912 {
1913 return double.NaN;
1914 }
1915 if (num == 0)
1916 {
1917 return 0.0;
1918 }
1919 if (num3 == 0 && num <= 9)
1920 {
1921 int num4 = *ptr3 & 0xF;
1922 while (--num != 0)
1923 {
1924 ptr3++;
1925 num4 = num4 * 10 + (*ptr3 & 0xF);
1926 }
1927 return (num2 < 0) ? (-num4) : num4;
1928 }
1929 if (num > 50)
1930 {
1931 ptr2 -= num - 50;
1932 num3 += num - 50;
1933 num = 50;
1934 }
1935 while (true)
1936 {
1937 if (*(--ptr2) == '0')
1938 {
1939 num--;
1940 num3++;
1941 }
1942 else if (*ptr2 != '.')
1943 {
1944 break;
1945 }
1946 }
1947 ptr2++;
1948 FloatingDecimal floatingDecimal = new FloatingDecimal();
1952 fixed (byte* ptr5 = &floatingDecimal.Mantissa[0])
1953 {
1954 byte* ptr6 = ptr5;
1955 for (; ptr3 < ptr2; ptr3++)
1956 {
1957 if (*ptr3 != '.')
1958 {
1959 *ptr6 = (byte)(*ptr3 & 0xFu);
1960 ptr6++;
1961 }
1962 }
1963 }
1964 return (double)floatingDecimal;
1965 }
1966 }
static bool IsWhitespace(char ch)
static bool IsAsciiDigit(char ch)
static unsafe char * SkipWhitespace(char *pch)

References System.Xml.Dictionary, System.Xml.Xsl.XPathConvert.IsAsciiDigit(), System.Xml.Xsl.XPathConvert.IsWhitespace(), System.s, and System.Xml.Xsl.XPathConvert.SkipWhitespace().

Referenced by System.Xml.Xsl.Xslt.QilGenerator.CompileGroupingSizeAttribute(), System.Xml.Xsl.Xslt.XsltLoader.LoadTemplate(), System.Xml.Xsl.XPath.XPathParser< Node >.ParsePrimaryExpr(), System.Xml.Xsl.Xslt.XsltInput.SetVersion(), System.Xml.Xsl.Runtime.XsltConvert.ToDouble(), and System.Xml.Xsl.Runtime.XsltConvert.ToDouble().