// z.Quo divides two ConstNumbers, promoting the type
// automatically. If both operands are of ConstInt, then integer
// division is performed.
963784
func (z *ConstNumber) Quo(x, y *ConstNumber) *ConstNumber {
	z.Type = promoteConstNumbers(x.Type, y.Type)
	if z.Type.IsIntegral() {
		z.Value.Re.Num().Div(x.Value.Re.Num(), y.Value.Re.Num())
	} else {
		z.Value.Quo(&x.Value, &y.Value)
	}
	return z
}
147258
func Pow(z, x, y *decimal.Big) *decimal.Big {
	if z.CheckNaNs(x, y) {
		return z
	}

	if xs := x.Sign(); xs <= 0 {
		if xs == 0 {
			if y.Sign() == 0 {
				// 0 ** 0 is undefined
				z.Context.Conditions |= decimal.InvalidOperation
				return z.SetNaN(false)
			}
			if y.Signbit() {
				// 0 ** -y = +Inf
				return z.SetInf(true)
			}
			// 0 ** y = 0
			return z.SetUint64(0)
		}
		if xs < 0 && (!y.IsInt() || y.IsInf(0)) {
			// -x ** y.vvv is undefined
			// -x ** ±Inf is undefined
			z.Context.Conditions |= decimal.InvalidOperation
			return z.SetNaN(false)
		}
	}

	if x.IsInf(0) {
		switch y.Sign() {
		case +1:
			// ±Inf ** y = +Inf
			return z.SetInf(false)
		case -1:
			// ±Inf ** -y = 0
			return z.SetUint64(0)
		case 0:
			// ±Inf ** 0 = 1
			return z.SetUint64(1)
		}
	}

	if y.Sign() == 0 {
		// x ** 0 = 1
		return z.SetUint64(1)
	}

	if x.Cmp(ptFive) == 0 {
		// x ** 0.5 = sqrt(x)
		return Sqrt(z, x)
	}

	if y.IsInt() {
		return powInt(z, x, y)
	}
	return powDec(z, x, y)
}
1211787
func (tzm *tzm) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
	return locales.PluralRuleUnknown
}
622846
func (curve *KoblitzCurve) doubleJacobian(x1, y1, z1, x3, y3, z3 *fieldVal) {
	// Doubling a point at infinity is still infinity.
	if y1.IsZero() || z1.IsZero() {
		x3.SetInt(0)
		y3.SetInt(0)
		z3.SetInt(0)
		return
	}

	// Slightly faster point doubling can be achieved when the z value is 1
	// by avoiding the multiplication on the z value.  This section calls
	// a point doubling function which is accelerated by using that
	// assumption when possible.
	if z1.Normalize().Equals(fieldOne) {
		curve.doubleZ1EqualsOne(x1, y1, x3, y3, z3)
		return
	}

	// Fall back to generic point doubling which works with arbitrary z
	// values.
	curve.doubleGeneric(x1, y1, z1, x3, y3, z3)
}
667123
func (ro *ro) CardinalPluralRule(num float64, v uint64) locales.PluralRule {

	n := math.Abs(num)
	i := int64(n)
	nMod100 := math.Mod(n, 100)

	if i == 1 && v == 0 {
		return locales.PluralRuleOne
	} else if (v != 0) || (n == 0) || (n != 1 && nMod100 >= 1 && nMod100 <= 19) {
		return locales.PluralRuleFew
	}

	return locales.PluralRuleOther
}
113055
func NextPlus(z, x *decimal.Big) *decimal.Big {
	if z.CheckNaNs(x, nil) {
		return z
	}

	if x.IsInf(0) {
		if x.IsInf(+1) {
			return z.SetInf(false)
		}
		_, m := decimal.Raw(z)
		maxfor(m, precision(z), -1)
		return z.SetBigMantScale(m, -etop(z))
	}

	ctx := z.Context
	ctx.RoundingMode = decimal.ToPositiveInf
	ctx.Set(z, x)
	ctx.Add(z, x, new(decimal.Big).SetMantScale(1, -etiny(z)+1))
	z.Context.Conditions &= ctx.Conditions
	return z
}
1369015
func (z Zones) Normalize() {
	for i := range z {
		z[i] = Name(z[i]).Normalize()
	}
}
304382
func (z *ConstNumber) Mul(x, y *ConstNumber) *ConstNumber {
	z.Type = promoteConstNumbers(x.Type, y.Type)
	z.Value.Mul(&x.Value, &y.Value)
	return z
}
1021887
func (z *ConstNumber) Add(x, y *ConstNumber) *ConstNumber {
	z.Type = promoteConstNumbers(x.Type, y.Type)
	z.Value.Add(&x.Value, &y.Value)
	return z
}
95234
func ln10(z *decimal.Big, prec int) *decimal.Big {
	if prec <= constPrec {
		// Copy takes 1/2 the time as ctx.Set since there's no rounding and in
		// most of our algorithms we just need >= prec.
		return z.Copy(_Ln10)
	}

	ctx := decimal.Context{Precision: prec + 10}
	g := lgen{
		ctx: ctx,
		pow: eightyOne, // 9 * 9
		z2:  eleven,    // 9 + 2
		k:   -1,
		t:   Term{A: new(decimal.Big), B: new(decimal.Big)},
	}
	ctx.Quo(z, eighteen /* 9 * 2 */, Wallis(z, &g))
	ctx.Precision = prec
	return ctx.Round(z)
}
605509
func calc(v1, v2 interface{}, op int) interface{} {

	i1, ok := _int64(v1)
	i2, ok2 := _int64(v2)

	var ok3, ok4 bool
	var i3, i4 float64

	if !ok {
		i3, ok3 = _float64(v1)
	}
	if !ok2 {
		i4, ok4 = _float64(v2)
	}

	if ok && ok2 {
		switch op {
		case '+':
			return i1 + i2
		case '-':
			return i1 - i2
		case '*':
			return i1 * i2
		case '/':
			return i1 / i2
		case '%':
			return i1 % i2
		}
	}
	if ok3 && ok4 {
		switch op {
		case '+':
			return i3 + i4
		case '-':
			return i3 - i4
		case '*':
			return i3 * i4
		case '/':
			return i3 / i4
		case '%':
			return int(i3) % int(i4)
		}
	}
	if ok && ok4 {
		i3 = float64(i1)
		switch op {
		case '+':
			return i3 + i4
		case '-':
			return i3 - i4
		case '*':
			return i3 * i4
		case '/':
			return i3 / i4
		case '%':
			return i1 % int64(i4)
		}
	}
	if ok3 && ok2 {
		i4 = float64(i2)
		switch op {
		case '+':
			return i3 + i4
		case '-':
			return i3 - i4
		case '*':
			return i3 * i4
		case '/':
			return i3 / i4
		case '%':
			return int64(i3) % i2
		}
	}

	if op != '+' {
		return nil
	}

	return _string(v1) + _string(v2)
}
321375
func promoteConstToTyped(from ConstType, c constValue, to reflect.Type, expr Expr) (
	constValue, []error) {
        return convertConstToTyped(from, c, to, false, expr)
}
981732
func (x Pol) GCD(f Pol) Pol {
	if f == 0 {
		return x
	}

	if x == 0 {
		return f
	}

	if x.Deg() < f.Deg() {
		x, f = f, x
	}

	return f.GCD(x.Mod(f))
}
158230
func (u *Ugen) Frac() Input {
	return unaryOpFrac(u.Rate, u, u.NumOutputs)
}
813252
func (c Context) QuoRem(z, x, y, r *Big) (*Big, *Big) {
	if debug {
		x.validate()
		y.validate()
	}
	if z.invalidContext(c) {
		r.invalidContext(c)
		return z, r
	}

	sign := (x.form & signbit) ^ (y.form & signbit)
	if x.IsFinite() && y.IsFinite() {
		if y.isZero() {
			if x.isZero() {
				// 0 / 0
				z.setNaN(InvalidOperation|DivisionUndefined, qnan, quo00)
				r.setNaN(InvalidOperation|DivisionUndefined, qnan, quo00)
			}
			// x / 0
			z.Context.Conditions |= DivisionByZero
			r.Context.Conditions |= DivisionByZero
			return z.SetInf(sign != 0), r.SetInf(x.Signbit())
		}
		if x.isZero() {
			// 0 / y
			z.setZero((x.form^y.form)&signbit, 0)
			r.setZero(x.form, y.exp-x.exp)
			return c.fix(z), c.fix(r)
		}
		return c.quorem(z, r, x, y)
	}

	// NaN / NaN
	// NaN / y
	// x / NaN
	if z.checkNaNs(x, y, division) {
		return z, r.Set(z)
	}

	if x.form&inf != 0 {
		if y.form&inf != 0 {
			// ±Inf / ±Inf
			z.setNaN(InvalidOperation, qnan, quoinfinf)
			return z, r.Set(z)
		}
		// ±Inf / y
		return z.SetInf(sign != 0), r.SetInf(x.form&signbit != 0)
	}
	// x / ±Inf
	z.Context.Conditions |= Clamped
	z.setZero(sign, c.etiny())
	r.setZero(x.form&signbit, 0)
	return z, r
}
1094831
func (primative *Primative) AsInteger() (int64, error) {
	switch val := primative.value.(type) {
	case bool:
		intVal := int64(0)
		if val {
			intVal = int64(1)
		}
		return intVal, nil
	case float64:
		return int64(math.Trunc(val)), nil
	case int64:
		return val, nil
	case string:
		return strconv.ParseInt(val, 10, 64)
	}

	msg := fmt.Sprintf("Could not convert value %s to type INTEGER", primative.value)
	return 0, errors.New(msg)
}
840725
func (gf *GaloisField) Multiply(a, b int) int {
	if a == 0 || b == 0 {
		return 0
	}
	return gf.ALogTbl[(gf.LogTbl[a]+gf.LogTbl[b])%(gf.Size-1)]
}