-
Notifications
You must be signed in to change notification settings - Fork 648
Open
Description
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"
)
func main() {
x := decimal.NewFromInt(10).Pow(decimal.NewFromInt(-18))
fmt.Printf("10 to the power of -18 is %s", x)
}
-- go.mod --
module play.ground
require github.com/shopspring/decimal v1.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
Metadata
Metadata
Assignees
Labels
No labels