Skip to content

Precision: a machine number anywhere gives MachinePrecision, as in WMA - #2059

Merged
tombouctou merged 2 commits into
masterfrom
precision-machine-number
Oct 19, 2026
Merged

tombouctou merged 2 commits into
masterfrom
precision-machine-number

Conversation

@tombouctou

Copy link
Copy Markdown
Collaborator

Part of #2047: the older difference noted in #2050. Independent of the other open PRs: this one is against master.

In WMA, Precision of an expression that holds a machine number is MachinePrecision, whatever the other numbers are:

Input master this PR WMA 15
Precision[{{a, 2, 3.2`}, {2.13, 3.25, "a"}}] 3.32222 MachinePrecision MachinePrecision
Precision[{1.5`10, 1.5}] 10. MachinePrecision MachinePrecision
Precision[f[1.5`3, x, 2.]] 3. MachinePrecision MachinePrecision
Precision[{1.5`20, 1.5}] MachinePrecision MachinePrecision MachinePrecision

A flat list such as {1.520, 1.5} was right only because its lowest precision happened to equal the machine precision. The check now looks for a machine number in the expression (has_machine_number), not at the value. So an arbitrary-precision number with 15.9546 digits, such as N[Pi, $MachinePrecision]`, keeps its value, as in WMA.

Tests

In test_precision, the two lists from the table expected 3. and Precision[2.13]. They now expect `MachinePrecision`. Three new cases. The `Precision` doctest `Precision[{{1, 1.`},{1.`5, 1.`10}}]` expected `5.`; WMA gives `MachinePrecision`. It now shows both: with 1.20`` in place of ``1.``` it gives 5.`. Full run on kimmy: doctests all pass (4605). The pytest failures are the ones that depend on the order the tests run in; the failing files that touch numbers pass on their own.

🤖 Generated with Claude Code

tombouctou and others added 2 commits October 19, 2026 23:57
Part of MATH-227 (an older difference noted in #2050).

Precision[{{a, 2, 3.2`}, {2.1``3, 3.2``5, "a"}}] was 3.32222, the
lowest precision of the numbers; WMA gives MachinePrecision, as it does
whenever the expression holds a machine number. A flat list only got
that right because the lowest value happened to be the machine
precision. The check is now on the numbers themselves, so an
arbitrary-precision number with 15.9546 digits keeps its value.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… as in WMA

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rocky

rocky commented Oct 19, 2026

Copy link
Copy Markdown
Member

LGTM. Feel free to merge when CI finishes.

@tombouctou
tombouctou merged commit 7b41c86 into master Oct 19, 2026
15 checks passed
@tombouctou
tombouctou deleted the precision-machine-number branch October 19, 2026 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants