Skip to content

Commit 029c923

Browse files
committed
Use MachineReal() conversion in constants.
when precision not not specified or None. Otherwise use PrecsionReal
1 parent e107dd3 commit 029c923

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

mathics/builtin/constants.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ def get_constant(self, precision, evaluation, preference=None):
5959
d = get_precision(precision, evaluation)
6060
except PrecisionValueError:
6161
d = None
62-
## print("XXX1", self, preference)
62+
63+
conversion_fn = MachineReal if d is None else PrecisionReal
64+
65+
# print("XXX1", self, preference, conversion_fn)
6366

6467
if preference == "sympy" and hasattr(self, "sympy_name"):
6568
value = sympy_constant(self.sympy_name, d)
@@ -73,7 +76,7 @@ def get_constant(self, precision, evaluation, preference=None):
7376
value = sympy_constant(self.sympy_name, d)
7477
elif hasattr(self, "numpy_name"):
7578
value = numpy_constant(self.numpy_name)
76-
return PrecisionReal(value)
79+
return conversion_fn(value)
7780

7881

7982
class MPMathConstant(_Constant_Common):

0 commit comments

Comments
 (0)