-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Description
What version of Go are you using (go version)?
I'm using go.dev/play (2022-01-01 15:00)
Does this issue reproduce with the latest release?
https://go.dev/play/p/S-nYwa_t_uV
What operating system and processor architecture are you using (go env)?
I'm using go.dev/play (2022-01-01 15:00)
What did you do?
x = 999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 (150 digits)
I want to find the cubic root of x and need the exact number up to 10 decimal points. Thus the appropriate choice for the rounding is ToZero rounding mode, not ToNearestToEven.
The cubic root of x up to 600 decimal places is
99999999999999999999999999999999999999999999999999.999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999966666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666655555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555549382716049382716049382716049382716049382716049382716049382716049382716049382716049382716049382716049382716049382716049382716049382716049382716049383
What did you expect to see?
Edit: Let z be the cubic root of x and of type *big.Float.
I expect z.SetMode(big.ToZero).Text('f', 10) returns "99999999999999999999999999999999999999999999999999.9999999999"
What did you see instead?
(*Float).Text has no flexible rounding options. It just rounds with NearestEven.
z.SetMode(big.ToZero).Text('f', 10) returns "100000000000000000000000000000000000000000000000000.0000000000"
And z.Text('f', 550) returns the correct value because the digit after 550 decimal point do not affect.
It's the problem. (*Float).Text shall handle RoundingMode.