Example #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);
            }
        }
Example #2
0
#pragma warning disable RECS0146 // Member hides static member from outer class
            public static ExactReal Get(decimal value)
#pragma warning restore RECS0146 // Member hides static member from outer class
            {
                if (cache.ContainsKey(value))
                {
                    return(cache[value]);
                }
                ExactReal real = new ExactReal(value);

                cache.Add(value, real);
                return(real);
            }
Example #3
0
        public static Real Get(decimal value)
        {
            Number cachedKey = ExactReal.Get(value);

            if (cache.ContainsKey(cachedKey))
            {
                return(cache[cachedKey]);
            }
            Real result = new Real(cachedKey);

            cache.Add(cachedKey, result);
            return(result);
        }