Skip to content

Implement MachinePrecision option for large numbers that fall outside of Python's builtin float mantissa #1741

@rocky

Description

@rocky

Description

N[integer, MachinePrecision] is not implemented.

Currently, we are forcing N for a large Integer argument (doesn't fit into a float mantissa) to be PrecisionReal.

How to Reproduce and Output Given

In the source code that implements the evaluation function, remove lines 94-95 of mathics.core.eval.nevaluator:

if isinstance(expr, Number):
        return expr.round(d)

Now use N with MachinePrecision specified:

In[1]:= N[265613988875874769338781322035779626829233452653394495974574961739092490901302182994384699044001, MachinePrecision]
Out[1]= 265613988875874769338781322035779626829233452653394495974574961739092490901302182994384699044001

I believe this is showing that numeric conversion to MachinePrecision has not been implemented.

Expected behavior

In[2]:= N[3^200, MachinePrecision]                                                                        
Out[2]= 2.65614 10^95

Additional context

Related to issue #1740

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions