MCPcopy
hub / github.com/shopspring/decimal / PowBigInt

Method PowBigInt

decimal.go:912–914  ·  view source on GitHub ↗

PowBigInt returns d to the power of exp, where exp is big.Int. Only returns error when d and exp is 0, thus result is undefined. When exponent is negative the returned decimal will have maximum precision of PowPrecisionNegativeExponent places after decimal point. Example: d1, err := decimal.NewF

(exp *big.Int)

Source from the content-addressed store, hash-verified

910// d2, err := decimal.NewFromFloat(629.25).PowBigInt(big.NewInt(5))
911// d2.String() // output: "98654323103449.5673828125"
912func (d Decimal) PowBigInt(exp *big.Int) (Decimal, error) {
913 return d.powBigIntWithPrecision(exp, int32(PowPrecisionNegativeExponent))
914}
915
916func (d Decimal) powBigIntWithPrecision(exp *big.Int, precision int32) (Decimal, error) {
917 if d.IsZero() && exp.Sign() == 0 {

Callers 4

PowMethod · 0.95
TestDecimal_PowBigIntFunction · 0.80

Calls 1

Tested by 3

TestDecimal_PowBigIntFunction · 0.64