Skip to content

math: defined constants are about 210 bits instead of allowed 256 bits mantissa #74673

@ldemailly

Description

@ldemailly

Go version

all so far

Output of go env in your module/workspace:

n/a

What did you do?

Looked at/used math.Pi
https://cs.opensource.google/go/go/+/refs/tags/go1.24.5:src/math/const.go;l=13

	Pi  = 3.14159265358979323846264338327950288419716939937510582097494459 // https://oeis.org/A000796

What did you see happen?

It has has 63 digits, so 209.2 ~210 bits of mantissa precision

What did you expect to see?

Should have 78+ plus digits or have all the digits mentioned on the link https://oeis.org/A000796/constant (105 digits)

3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214

To get the 256+ bits the spec says

https://go.dev/ref/spec#Constants

Represent floating-point constants, including the parts of a complex constant, with a mantissa of at least 256 bits and a signed binary exponent of at least 16 bits.

(about 46 bits missing at the moment)

ps: Pi here is just an example, all the constants in that file have the same issue with truncated digits below the spec resolution

Metadata

Metadata

Assignees

No one assigned

    Labels

    FeatureRequestIssues asking for a new feature that does not need a proposal.NeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions