Skip to content

N[3^200] in formats as PrecisionReal instead of MachinePrecision #1740

@rocky

Description

@rocky

Description

Numeric conversion N is converting to a PrecisionReal.

How to Reproduce and Output Given

Here is what we give:

In[1]:= N[3^200]
Out[1]= 2.65613988875875×10^95

In[16]:= N[Sqrt[19]]
Out[16]= 4.3588989435406735522369

We should get:

In[1]:= N[3^200]
Out[1]= 2.65614×10^95

In[2]:= N[Sqrt[19]]
Out[2]= 4.3589

Priority

Probably an easy fix. Should do before release.

https://github.com/Mathics3/mathics-core/blob/master/mathics/format/form/outputform.py#L752

        digits = dps(n.get_precision()) if isinstance(n, PrecisionReal) else 6

seems to be the offending line. The precision of the number is not the same thing as the display precision, whose default is 6. This is implicitly described in https://reference.wolfram.com/language/howto/ChangeTheFormatOfNumbers.html and https://reference.wolfram.com/language/ref/DefaultPrintPrecision.html

We might give thought on how to handle the DefaultPrintPrecision option.

Additional context

Noticed in going over discrepancies in a video on Mathematica, comparing output with what we have.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions