shopspring / decimal

Arbitrary-precision fixed-point decimal numbers in Go
Other
6.44k stars 624 forks source link

decimal.Pow result fail #242

Open bendh1 opened 3 years ago

bendh1 commented 3 years ago

input: fmt.Println(math.Pow(0.0208333333333333, 0.33)) fmt.Println(decimal.NewFromFloat(0.0208333333333333).Pow(decimal.NewFromFloat(0.33)))

ouput: 0.2787342852450195 1

can you help me?

mwoss commented 3 years ago

Hi @bendh1! Unfortunately Pow method is only working with Integer exponents right now. This is ongoing issue that must be fixed and we are aware of that. First PR that address this issue have been created some time ago by my #229, but I don't have enough time to polish it and merge to main branch :< Sorry for any inconvenience.

mwoss commented 8 months ago

I've finally implemented an improved Pow method. Please take a look at this comment: https://github.com/shopspring/decimal/issues/55#issuecomment-2033204145