// positiveScaleInt64 multiplies base by 10^scale, returning false if the
// value overflows. Passing a negative scale is undefined.
328239
func positiveScaleInt64(base int64, scale Scale) (int64, bool) {
	switch scale {
	case 0:
		return base, true
	case 1:
		return int64MultiplyScale10(base)
	case 2:
		return int64MultiplyScale100(base)
	case 3:
		return int64MultiplyScale1000(base)
	case 6:
		return int64MultiplyScale(base, 1000000)
	case 9:
		return int64MultiplyScale(base, 1000000000)
	default:
		value := base
		var ok bool
		for i := Scale(0); i < scale; i++ {
			if value, ok = int64MultiplyScale(value, 10); !ok {
				return 0, false
			}
		}
		return value, true
	}
}
32987
func parseInt64(d []byte) (n int64) {
	if len(d) == 0 {
		return -1
	}
	for _, dec := range d {
		if dec < asciiZero || dec > asciiNine {
			return -1
		}
		n = n*10 + (int64(dec) - asciiZero)
	}
	return n
}
1322649
func (k *Key) StrictFloat64s(delim string) ([]float64, error) {
	return k.parseFloat64s(k.Strings(delim), false, true)
}
248573
func (a *int64Amount) Add(b int64Amount) bool {
	switch {
	case b.value == 0:
		return true
	case a.value == 0:
		a.value = b.value
		a.scale = b.scale
		return true
	case a.scale == b.scale:
		c, ok := int64Add(a.value, b.value)
		if !ok {
			return false
		}
		a.value = c
	case a.scale > b.scale:
		c, ok := positiveScaleInt64(a.value, a.scale-b.scale)
		if !ok {
			return false
		}
		c, ok = int64Add(c, b.value)
		if !ok {
			return false
		}
		a.scale = b.scale
		a.value = c
	default:
		c, ok := positiveScaleInt64(b.value, b.scale-a.scale)
		if !ok {
			return false
		}
		c, ok = int64Add(a.value, c)
		if !ok {
			return false
		}
		a.value = c
	}
	return true
}
1076473
func Float64() float64 {
	mu.Lock()
	res := r.Float64()
	mu.Unlock()
	return res
}
521648
func (lr *LockedRand) Float64() (n float64) {
	lr.lk.Lock()
	n = lr.r.Float64()
	lr.lk.Unlock()
	return
}
614239
func _float64(i interface{}) (float64, bool) {

	switch v := i.(type) {

	case float32:
		return float64(v), true
	case float64:
		return v, true
	}

	return 0, false
}
590489
func (d *defaulter) AsInt64(v Valuer, dv int64) int64 {
	value, err := v.Value()
	if err != nil {
		d.logValuerError(err)
		return dv
	}
	ivalue, err := strconv.ParseInt(value, 10, 64)
	if err != nil {
		d.logFormatError("int64", err)
		return dv
	}
	return int64(ivalue)
}
586264
func (x *Big) Uint64() (uint64, bool) {
	if debug {
		x.validate()
	}

	if !x.IsFinite() || x.Signbit() {
		return 0, false
	}

	// x might be too large to fit into an uint64 *now*, but rescaling x might
	// shrink it enough. See issue #20.
	if !x.isCompact() {
		xb := x.Int(nil)
		return xb.Uint64(), xb.IsUint64()
	}

	b := x.compact
	if x.exp == 0 {
		return b, true
	}
	return scalex(b, x.exp)
}
1047424
func (q *Quantity) AsInt64() (int64, bool) {
	if q.d.Dec != nil {
		return 0, false
	}
	return q.i.AsInt64()
}
663778
func (i Int) Uint64() (_ uint64, ok bool) {
	x, acc := bigintToUint64(i.bigint)
	if acc != big.Exact {
		return // inexact
	}
	return x, true
}
92228
func (k *Key) ValidInt64s(delim string) []int64 {
	vals, _ := k.parseInt64s(k.Strings(delim), false, false)
	return vals
}
543915
func PackInt64(cmd BufferEx, val int64) (int, error) {
	return packAInt64(cmd, val)
}
1177593
func (c *JSONConfigContainer) DefaultInt64(key string, defaultval int64) int64 {
	if v, err := c.Int64(key); err == nil {
		return v
	}
	return defaultval
}
499250
func ToInt64(in interface{}) (int64, error) {
	if val, err := ToInt64E(in); err == nil {
		return val, nil
	}
	return 0, ErrBadType
}
1230385
func MulInt64(a int64, b int64) (int64, error) {
	if a == 0 || b == 0 {
		return 0, nil
	}

	var (
		res      uint64
		err      error
		negative = false
	)

	if a > 0 && b > 0 {
		res, err = MulUint64(uint64(a), uint64(b))
	} else if a < 0 && b < 0 {
		res, err = MulUint64(uint64(-a), uint64(-b))
	} else if a < 0 && b > 0 {
		negative = true
		res, err = MulUint64(uint64(-a), uint64(b))
	} else {
		negative = true
		res, err = MulUint64(uint64(a), uint64(-b))
	}

	if err != nil {
		return 0, errors.Trace(err)
	}

	if negative {
		// negative result
		if res > math.MaxInt64+1 {
			return 0, errors.Trace(ErrArithOverflow)
		}

		return -int64(res), nil
	}

	// positive result
	if res > math.MaxInt64 {
		return 0, errors.Trace(ErrArithOverflow)
	}

	return int64(res), nil
}
73426
func (ung UniformGenerator) Float64() float64 {
	ung.mu.Lock()
	defer ung.mu.Unlock()
	return ung.rd.Float64()
}