// NumberToInt converts a number x to an integer value.
// An int is returned unchanged, a float is truncated towards zero.
// NumberToInt reports an error for all other values.
421902
func NumberToInt(x Value) (Int, error) {
	switch x := x.(type) {
	case Int:
		return x, nil
	case Float:
		f := float64(x)
		if math.IsInf(f, 0) {
			return zero, fmt.Errorf("cannot convert float infinity to integer")
		} else if math.IsNaN(f) {
			return zero, fmt.Errorf("cannot convert float NaN to integer")
		}
		return finiteFloatToInt(x), nil

	}
	return zero, fmt.Errorf("cannot convert %s to int", x.Type())
}
255068
func (m *MT19937) Int() int {
	u := uint(m.Int64())
	return int(u << 1 >> 1)
}
911787
func (r *Reader) toInt(input string) int {
	result, err := strconv.Atoi(prune(input))
	if err != nil {
		return -1
	}
	return result
}
90393
func IntToTrits(value int64) Trits {
	if value == 0 {
		return Trits{0}
	}

	negative := value < 0
	size := MinTrits(value)
	valueAbs := MustAbsInt64(value)

	t := make(Trits, size)

	for i := 0; i < int(size); i++ {
		if valueAbs == 0 {
			break
		}
		trit := int8((valueAbs+1)%(TrinaryRadix) - 1)
		if negative {
			trit = -trit
		}
		t[i] = trit
		valueAbs++
		valueAbs /= TrinaryRadix
	}

	return t
}
175876
func (s *Statement) Int() *Statement {
	// notest
	t := token{
		content: "int",
		typ:     identifierToken,
	}
	*s = append(*s, t)
	return s
}
112036
func ConvertIntToInt(val int64, lowerBound int64, upperBound int64, tp byte) (int64, error) {
	if val < lowerBound {
		return lowerBound, overflow(val, tp)
	}

	if val > upperBound {
		return upperBound, overflow(val, tp)
	}

	return val, nil
}
257853
func ToInt(n int) [4]byte {
	s := make([]byte, 4)
	binary.LittleEndian.PutUint32(s, uint32(n))
	a := [4]byte{}
	copy(a[:], s[:4])
	return a
}
181380
func (j *JSON) Int(name string) (int, error) {
	v, err := j.value(name)
	if err != nil {
		return 0, err
	}

	f, ok := v.(float64)
	if !ok {
		return 0, errors.New(fmt.Sprintf("%T unable", v))
	}

	return int(f), nil
}
628671
func (p Properties) Int(key string, def int64) int64 {
	if v, found := p[key]; found {
		if b, err := strconv.ParseInt(v, 0, 64); err == nil {
			return b
		}
	}
	return def
}
693672
func (l *Locking) Int() (v int) {
	l.Lock()
	v = l.R.Int()
	l.Unlock()
	return
}
973514
func BigratToInt(bigrat *big.Rat) (int64, error) {
	float_string := bigrat.FloatString(0)
	return strconv.ParseInt(float_string, 10, 64)
}
377063
func ValueToInt(val Value) (int, bool) {
	iv, ok := ValueToInt64(val)
	return int(iv), ok
}
774876
func (s *DynamicBanScore) Int() uint32 {
	s.mtx.Lock()
	r := s.int(time.Now())
	s.mtx.Unlock()
	return r
}
1074343
func number(itf interface{}) interface{} {

	if itf == nil {
		return nil
	}

	f, ok := _float64(itf)
	if ok {
		return f
	}

	i, ok := _int64(itf)
	if ok {
		return i
	}

	s := _string(itf)
	if len(s) == 0 {
		return nil
	}

	if isInteger(s) {
		n, err := strconv.ParseInt(s, 10, 64)
		if err != nil {
			return nil
		}
		return n
	}

	n, err := strconv.ParseFloat(s, 64)
	if err != nil {
		return nil
	}
	return n
}
272461
func (a Adder) Int(x int, s ...string) {
	a(float64(x), s...)
}
1140228
func Int(name string, value int, usage string) *int {
	return CommandLine.Int(name, value, usage)
}
907142
func (L *State) ToInteger(index int) int {
	return int(C.lua_tointeger(L.s, C.int(index)))
}