You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Pow() returns different values for certain exponents across different releases.
In Go Playground, try the following code:
package main
import (
"fmt""github.com/shopspring/decimal"
)
funcmain() {
x:=decimal.NewFromInt(10).Pow(decimal.NewFromInt(-18))
fmt.Printf("10 to the power of -18 is %s", x)
}
--go.mod--moduleplay.groundrequiregithub.com/shopspring/decimalv1.4.0//require github.com/shopspring/decimal v1.3.1
v1.4.0 returns 0 while v1.3.1 returns 0.000000000000000001
After a bit of testing, it looks like for v1.4.0, with base 10 and any integer exponent <= -17 will return 0
For v1.3.1, with base 10 and any odd integer exponent <= -17 will return 0, while even integer exponents return the correct result.
The expectation is for all negative integer exponents to return the correct result (0.1, 0.001, 0.0001, etc)
Tested on go version go1.23.4 darwin/arm64
The text was updated successfully, but these errors were encountered:
Pow() returns different values for certain exponents across different releases.
In Go Playground, try the following code:
v1.4.0 returns
0
while v1.3.1 returns0.000000000000000001
After a bit of testing, it looks like for v1.4.0, with base
10
and any integer exponent <=-17
will return0
For v1.3.1, with base
10
and any odd integer exponent <=-17
will return0
, while even integer exponents return the correct result.The expectation is for all negative integer exponents to return the correct result (
0.1
,0.001
,0.0001
, etc)Tested on
go version go1.23.4 darwin/arm64
The text was updated successfully, but these errors were encountered: