// CoerceNumber coerces the given value into a number. Zero (0) is returned
// if the value cannot be coerced.
320702
func CoerceNumber(v Value) float64 {
	switch vc := v.(type) {
	case SafeValue:
		return CoerceNumber(vc.Value())
	case Number:
		return vc.Number()
	case uint:
		return float64(vc)
	case uint8:
		return float64(vc)
	case uint16:
		return float64(vc)
	case uint32:
		return float64(vc)
	case uint64:
		return float64(vc)
	case int:
		return float64(vc)
	case int8:
		return float64(vc)
	case int16:
		return float64(vc)
	case int32:
		return float64(vc)
	case int64:
		return float64(vc)
	case float32:
		return float64(vc)
	case float64:
		return vc
	case decimal.Decimal:
		f, _ := vc.Float64()
		return f
	case Stringer:
		return stringToFloat(vc.String())
	case string:
		return stringToFloat(vc)
	case Boolean:
		if vc.Boolean() {
			return 1
		}
	case bool:
		if vc {
			return 1
		}
	}
	return 0
}
1093005
func (t *Translator) FormatNumber(number float64) string {
	return t.formatNumber(t.parseFormat(t.rules.Numbers.Formats.Decimal, true), number)
}
928033
func (i *Issue) GetNumber() int {
	if i == nil || i.Number == nil {
		return 0
	}
	return *i.Number
}
224116
func (e *Expect) Number(value float64) *Number {
	return NewNumber(e.config.Reporter, value)
}
633324
func CoerceDatum(sc *variable.StatementContext, a, b Datum) (x, y Datum, err error) {
	if a.IsNull() || b.IsNull() {
		return x, y, nil
	}
	var (
		hasUint    bool
		hasDecimal bool
		hasFloat   bool
	)
	x = a.convergeType(&hasUint, &hasDecimal, &hasFloat)
	y = b.convergeType(&hasUint, &hasDecimal, &hasFloat)
	if hasFloat {
		switch x.Kind() {
		case KindInt64:
			x.SetFloat64(float64(x.GetInt64()))
		case KindUint64:
			x.SetFloat64(float64(x.GetUint64()))
		case KindMysqlHex:
			x.SetFloat64(x.GetMysqlHex().ToNumber())
		case KindMysqlBit:
			x.SetFloat64(x.GetMysqlBit().ToNumber())
		case KindMysqlEnum:
			x.SetFloat64(x.GetMysqlEnum().ToNumber())
		case KindMysqlSet:
			x.SetFloat64(x.GetMysqlSet().ToNumber())
		case KindMysqlDecimal:
			fval, err := x.ToFloat64(sc)
			if err != nil {
				return x, y, errors.Trace(err)
			}
			x.SetFloat64(fval)
		}
		switch y.Kind() {
		case KindInt64:
			y.SetFloat64(float64(y.GetInt64()))
		case KindUint64:
			y.SetFloat64(float64(y.GetUint64()))
		case KindMysqlHex:
			y.SetFloat64(y.GetMysqlHex().ToNumber())
		case KindMysqlBit:
			y.SetFloat64(y.GetMysqlBit().ToNumber())
		case KindMysqlEnum:
			y.SetFloat64(y.GetMysqlEnum().ToNumber())
		case KindMysqlSet:
			y.SetFloat64(y.GetMysqlSet().ToNumber())
		case KindMysqlDecimal:
			fval, err := y.ToFloat64(sc)
			if err != nil {
				return x, y, errors.Trace(err)
			}
			y.SetFloat64(fval)
		}
	} else if hasDecimal {
		var dec *MyDecimal
		dec, err = ConvertDatumToDecimal(sc, x)
		if err != nil {
			return x, y, errors.Trace(err)
		}
		x.SetMysqlDecimal(dec)
		dec, err = ConvertDatumToDecimal(sc, y)
		if err != nil {
			return x, y, errors.Trace(err)
		}
		y.SetMysqlDecimal(dec)
	}
	return
}
1374435
func getNegativeNumber(b []rune) int {
	if b[0] != '-' {
		return 0
	}

	i := 1
	for ; i < len(b); i++ {
		if !isDigit(b[i]) {
			return i
		}
	}

	return i
}
947091
func (t *TeamDiscussion) GetNumber() int {
	if t == nil || t.Number == nil {
		return 0
	}
	return *t.Number
}
49891
func (s *PublicBlockChainAPI) BlockNumber() hexutil.Uint64 {
	header, _ := s.b.HeaderByNumber(context.Background(), rpc.LatestBlockNumber) // latest header should always be available
	return hexutil.Uint64(header.Number.Uint64())
}
61423
func (L *State) OptNumber(narg int, d float64) float64 {
	return float64(C.luaL_optnumber(L.s, C.int(narg), C.lua_Number(d)))
}
99679
func UseNumber() {
	json = jsoniter.Config{
		UseNumber:              true,
		EscapeHTML:             true,
		SortMapKeys:            true,
		ValidateJsonRawMessage: true,
	}.Froze()
}
631047
func (a *Attribute) numberComparator(b *Attribute) (int, bool) {
	// If they are both integers we do perfect precision comparisons
	if a.Int != nil && b.Int != nil {
		return a.intComparator(b)
	}

	// Push both into the float space
	af := a.getBigFloat()
	bf := b.getBigFloat()
	if af == nil || bf == nil {
		return 0, false
	}

	return af.Cmp(bf), true
}
398399
func (ff *ff_GN) FmtNumber(num float64, v uint64) string {

	return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
}
950324
func GetNumBase(num string) (string, int) {
	switch {
	case len(num) == 0:
		return num, 10

	case len(num) > 1 && num[0] == '0':
		if num[1] == 'x' {
			return num[2:], 16
		}
		return num[1:], 8
	}
	return num, 10
}
731846
func ParseNumber(f interface{}) (uint32, error) {
	// Useful for tests
	if n, ok := f.(uint32); ok {
		return n, nil
	}

	s, ok := f.(string)
	if !ok {
		return 0, newParseError("expected a number, got a non-atom")
	}

	nbr, err := strconv.ParseUint(s, 10, 32)
	if err != nil {
		return 0, &parseError{err}
	}

	return uint32(nbr), nil
}
567911
func LVAsNumber(v LValue) LNumber {
	switch lv := v.(type) {
	case LNumber:
		return lv
	case LString:
		if num, err := parseNumber(string(lv)); err == nil {
			return num
		}
	}
	return LNumber(0)
}
1197243
func NewNumber() *Number {
	r := &Number{
		Buckets: make(map[int64]*numberBucket),
		Mutex:   &sync.RWMutex{},
	}
	return r
}
1304963
func (p *PullRequest) GetNumber() int {
	if p == nil || p.Number == nil {
		return 0
	}
	return *p.Number
}