IntPow computes the value of x^y.
(x, y DInt)
| 5351 | |
| 5352 | // IntPow computes the value of x^y. |
| 5353 | func IntPow(x, y DInt) (*DInt, error) { |
| 5354 | xd := apd.New(int64(x), 0) |
| 5355 | yd := apd.New(int64(y), 0) |
| 5356 | _, err := DecimalCtx.Pow(xd, xd, yd) |
| 5357 | if err != nil { |
| 5358 | return nil, err |
| 5359 | } |
| 5360 | i, err := xd.Int64() |
| 5361 | if err != nil { |
| 5362 | return nil, ErrIntOutOfRange |
| 5363 | } |
| 5364 | return NewDInt(DInt(i)), nil |
| 5365 | } |
| 5366 | |
| 5367 | // PickFromTuple picks the greatest (or least value) from a tuple. |
| 5368 | func PickFromTuple(ctx *EvalContext, greatest bool, args Datums) (Datum, error) { |