Ejemplo n.º 1
0
        public static Real Get(string value, int @base = 10)
        {
            if (value.Contains("#"))
            {
                double lowerBound = double.Parse(value.Replace('#', '0'));

                char   replace    = @base > 16 ? (char)('a' + (@base - 11)) : (char)('0' + @base - 1);
                double upperBound = double.Parse(value.Replace('#', replace));

                double primaryValue = (lowerBound + upperBound) / 2;

                InexactReal key = InexactReal.Get(lowerBound, upperBound, primaryValue, false);
                if (cache.ContainsKey(key))
                {
                    return(cache[key]);
                }
                Real result = new Real(key);
                cache.Add(key, result);
                return(result);
            }
            else
            {
                ExactReal key = ExactReal.Get(decimal.Parse(Integer.Get(value, @base).ToString()));
                if (cache.ContainsKey(key))
                {
                    return(cache[key]);
                }
                Real result = new Real(key);
                cache.Add(key, result);
                return(result);
            }
        }
Ejemplo n.º 2
0
        public static Real Get(double value)
        {
            InexactReal container = InexactReal.Get(value);

            if (cache.ContainsKey(container))
            {
                return(cache[container]);
            }
            cache.Add(container, new Real(value));
            return(cache[container]);
        }
Ejemplo n.º 3
0
 Real(double value)
 {
     Data = InexactReal.Get(value);
 }