// Abs sets z to the absolute value of x if x is finite and returns z. func (z *Big) Abs(x *Big) *Big { if x.form != finite { return z } if x.isCompact() { z.compact = arith.Abs(x.compact) } else { z.mantissa.Abs(&x.mantissa) } z.scale = x.scale z.ctx = x.ctx z.form = finite return z }
// MulPow10 computes 10 * x ** n and a bool indicating whether // the multiplcation was successful. func MulPow10(x int64, n int32) (p int64, ok bool) { if x == 0 || n <= 0 || x == c.Inflated { return x, true } if n < pow.Tab64Len && n < pow.ThreshLen { if x == 1 { return pow.Ten64(int64(n)) } if arith.Abs(int64(n)) < pow.Thresh(n) { p, ok := pow.Ten64(int64(n)) if !ok { return 0, false } return Mul(x, p) } } return 0, false }
// Mul returns x * y and a bool indicating whether the addition // was successful. func Mul(x, y int64) (prod int64, ok bool) { prod = x * y return prod, ((arith.Abs(x)|arith.Abs(y))>>31 == 0 || prod/y == x) }