Example #1
0
        public static bool O_Str2Decimal(string s, out double result)
        {
            result = 0.0;

            if (s.Contains("n") || s.Contains("N"))              // reject `inf' and `nan'
            {
                return(false);
            }

            int pos = 0;

            if (s.Contains("x") || s.Contains("X"))
            {
                result = Utl.StrX2Number(s, ref pos);
            }
            else
            {
                result = Utl.Str2Number(s, ref pos);
            }

            if (pos == 0)
            {
                return(false);                // nothing recognized
            }
            while (pos < s.Length && Char.IsWhiteSpace(s[pos]))
            {
                ++pos;
            }
            return(pos == s.Length);            // OK if no trailing characters
        }