Exemple #1
0
        public static bool TryParseInt64(string str, out long result)
        {
            result = 0;
            ulong r;
            bool  sign;

            if (Helper.TryParseUInt64Core(str, false, out r, out sign))
            {
                if (!sign)
                {
                    if (r <= 9223372036854775807)
                    {
                        result = unchecked ((long)r);
                        return(true);
                    }
                }
                else
                {
                    if (r <= 9223372036854775808)
                    {
                        result = unchecked (-((long)r));
                        return(true);
                    }
                }
            }
            return(false);
        }
Exemple #2
0
        /// <summary>
        /// Attempts to parse a number into a Uint32
        /// </summary>
        /// <param name="str"></param>
        /// <param name="style"></param>
        /// <param name="result"></param>
        /// <returns></returns>
        public static bool TryParseUInt32(string str, NumberEncoding style, out UInt32 result)
        {
            bool  sign;
            ulong tmp;

            bool bresult = Helper.TryParseUInt64Core(str, style == NumberEncoding.Hexadecimal ? true : false, out tmp, out sign);

            result = (UInt32)tmp;

            return(bresult && !sign);
        }
Exemple #3
0
        private static bool TryParseInt64Hex(string str, out ulong result)
        {
            bool sign;

            return(Helper.TryParseUInt64Core(str, true, out result, out sign));
        }