You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, RealDigits uses N[] to evaluate to the necessary precision before extracting digits. However, this involves rounding to the nearest digit, which differs from the behaviour of RealDigits in WMA.
In some cases you can work around it by evaluating to a greater precision than needed, but this doesn't work in general when there's e.g. an arbitrarily long series of 9s. It seems like the best solution would be to be able to supply a rounding mode to the numerical evaluation routines? MPMath has some support for setting rounding modes on individual operations, but there doesn't appear to be a global interface for it like there is for precision, and I'm not familiar enough with how this is used in mathics to trace every call that would need to changed to support this. I'm sure there's other cases I'm overlooking too.
How to Reproduce / Output Given
Mathics 7.0.1dev0
on CPython 3.12.3 (main, Sep 11 2024, 14:17:37) [GCC 13.2.0]
using SymPy 1.12, mpmath 1.3.0, numpy 1.26.4, cython Not installed
Copyright (C) 2011-2024 The Mathics3 Team.
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions.
See the documentation for the full license.
Quit by evaluating Quit[] or by pressing CONTROL-D.
In[1]:= RealDigits[1 - 10^-100, 10, 5]
Out[1]= {{1, 0, 0, 0, 0}, 1}
In[2]:= RealDigits[Sqrt[104], 10, 1, -1]
Out[2]= {{2}, 0}
Expected behavior
Wolfram Language 14.1.0 Engine for Microsoft Windows (64-bit)
Copyright 1988-2024 Wolfram Research, Inc.
In[1]:= RealDigits[1 - 10^-100, 10, 5]
Out[1]= {{9, 9, 9, 9, 9}, 0}
In[2]:= RealDigits[Sqrt[104], 10, 1, -1]
Out[2]= {{1}, 0}
The text was updated successfully, but these errors were encountered:
Description
Currently, RealDigits uses
N[]
to evaluate to the necessary precision before extracting digits. However, this involves rounding to the nearest digit, which differs from the behaviour of RealDigits in WMA.In some cases you can work around it by evaluating to a greater precision than needed, but this doesn't work in general when there's e.g. an arbitrarily long series of 9s. It seems like the best solution would be to be able to supply a rounding mode to the numerical evaluation routines? MPMath has some support for setting rounding modes on individual operations, but there doesn't appear to be a global interface for it like there is for precision, and I'm not familiar enough with how this is used in mathics to trace every call that would need to changed to support this. I'm sure there's other cases I'm overlooking too.
How to Reproduce / Output Given
Expected behavior
The text was updated successfully, but these errors were encountered: