// AsInt is the acessor for an Integer DataType.
// If d is Integer, it will return the (value, true), otherwise (0, false)
556015
func AsInt(d DataType) (int, bool) {
	value, ok := d.Value().(int)
	return value, ok
}
377542
func (t Result) Int() int64 {
	switch t.Type {
	default:
		return 0
	case True:
		return 1
	case String:
		n, _ := parseInt(t.Str)
		return n
	case Number:
		// try to directly convert the float64 to int64
		n, ok := floatToInt(t.Num)
		if !ok {
			// now try to parse the raw string
			n, ok = parseInt(t.Raw)
			if !ok {
				// fallback to a standard conversion
				return int64(t.Num)
			}
		}
		return n
	}
}
172440
func (v *Validator) TypeInt(field string) *ValidationResult {
	if _, err := strconv.Atoi(v.data.Get(field)); err != nil {
		return v.addTypeError(field, "integer")
	} else {
		return validationOk
	}
}
24344
func Int(key string, def int) int {
	val := os.Getenv(key)
	if val == "" {
		return def
	}

	i, err := strconv.Atoi(val)
	if err != nil {
		return def
	}
	return i
}
818587
func FromInt(data [4]byte) int {
	ui32 := binary.LittleEndian.Uint32(data[:])
	return int(ui32)
}
559878
func (b *buf) Int() int64 {
	ux, bits := b.Varint()
	x := int64(ux)
	if x&(1<<(bits-1)) != 0 {
		x |= -1 << bits
	}
	return x
}
245588
func (h *HCL) Int(name string) (int, error) {
	v, err := h.value(name)
	if err != nil {
		return 0, err
	}

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

		return i, nil
	}

	return int(f), nil
}
1360377
func (lr *LockedRand) Int() (n int) {
	lr.lk.Lock()
	n = lr.r.Int()
	lr.lk.Unlock()
	return
}
431842
func Asin(z, x *decimal.Big) *decimal.Big {
	if z.CheckNaNs(x, nil) {
		return z
	}

	cmp1 := x.CmpAbs(one)
	if x.IsInf(0) || cmp1 > 0 {
		z.Context.Conditions |= decimal.InvalidOperation
		return z.SetNaN(false)
	}

	ctx := decimal.Context{Precision: precision(z)}

	if cmp1 == 0 {
		pi2(z, ctx)
		if x.Signbit() {
			misc.SetSignbit(z, true)
		}
		return z
	}

	ctx.Precision += defaultExtraPrecision

	// Asin(x) = 2 * atan(x / (1 + sqrt(1 - x*x)))

	x2 := ctx.Mul(alias(z, x), x, x)
	ctx.Quo(x2, x, ctx.Add(x2, Sqrt(x2, ctx.Sub(x2, one, x2)), one))
	z.Copy(Atan(decimal.WithContext(ctx), x2))
	ctx.Mul(z, z, two)
	ctx.Precision -= defaultExtraPrecision
	return ctx.Round(z)
}
771969
func asin(a float64) float64 {
	var negateResult bool
	if a < 0 {
		a = -a
		negateResult = true
	}
	if a <= asinMaxValueForTabs {
		index := int(a*asinIndexer + 0.5)
		delta := a - float64(index)*asinDelta
		result := asinTab[index] + delta*(asinDer1DivF1Tab[index]+delta*(asinDer2DivF2Tab[index]+delta*(asinDer3DivF3Tab[index]+delta*asinDer4DivF4Tab[index])))
		if negateResult {
			return -result
		}
		return result
	}
	// value > ASIN_MAX_VALUE_FOR_TABS, or value is NaN
	// This part is derived from fdlibm.
	if a < 1 {
		t := (1.0 - a) * 0.5
		p := t * (asinPs0 + t*(asinPs1+t*(asinPs2+t*(asinPs3+t*(asinPs4+t+asinPs5)))))
		q := 1.0 + t*(asinQs1+t*(asinQs2+t*(asinQs3+t*asinQs4)))
		s := math.Sqrt(t)
		z := s + s*(p/q)
		result := asinPio2Hi - ((z + z) - asinPio2Lo)
		if negateResult {
			return -result
		}
		return result
	}
	// value >= 1.0, or value is NaN
	if a == 1.0 {
		if negateResult {
			return -math.Pi / 2
		}
		return math.Pi / 2
	}
	return math.NaN()
}
1319620
func GetInt(n ast.Node) (int64, error) {
	if node, ok := n.(*ast.BasicLit); ok && node.Kind == token.INT {
		return strconv.ParseInt(node.Value, 0, 64)
	}
	return 0, fmt.Errorf("Unexpected AST node type: %T", n)
}
1263855
func asInt(param string) int64 {

	i, err := strconv.ParseInt(param, 0, 64)
	panicIf(err)

	return i
}
94480
func (buf *Float32Buffer) AsIntBuffer() *IntBuffer {
	newB := &IntBuffer{SourceBitDepth: buf.SourceBitDepth}
	if newB.SourceBitDepth == 0 {
		newB.SourceBitDepth = 16
	}
	newB.Data = make([]int, len(buf.Data))
	// TODO: we might want to consider checking the min/max values
	// and if we are in a normalized float range, apply a denormalization.
	for i := 0; i < len(buf.Data); i++ {
		newB.Data[i] = int(buf.Data[i])
	}
	newB.Format = &Format{
		NumChannels: buf.Format.NumChannels,
		SampleRate:  buf.Format.SampleRate,
	}
	return newB
}
76434
func (g *Generator) Int(lo, hi int) int {
	if lo == hi {
		return lo
	}
	if lo > hi {
		lo, hi = hi, lo
	}
	n := g.rand.Intn(hi - lo + 1)
	return lo + n
}
671933
func (e Environment) Int(name string) (int, error) {
	v, err := e.value(name)
	if err != nil {
		return 0, err
	}

	i, err := strconv.Atoi(v)
	if err != nil {
		return 0, err
	}

	return i, nil
}
292870
func (e *Event) Int(key string, i int) *Event {
	if e == nil {
		return e
	}
	e.buf = enc.AppendInt(enc.AppendKey(e.buf, key), i)
	return e
}
4534
func (m *MT19937) Int() int {
	u := uint(m.Int32())
	return int(u << 1 >> 1)
}