// DecodeUint64 decodes msgpack int8/16/32/64 and uint8/16/32/64
// into Go uint64.
330925
func (d *Decoder) DecodeUint64() (uint64, error) {
	c, err := d.readCode()
	if err != nil {
		return 0, err
	}
	return d.uint(c)
}
608161
func (d *msgpackDecDriver) DecodeInt64() (i int64) {
	if !d.bdRead {
		d.readNextBd()
	}
	switch d.bd {
	case mpUint8:
		i = int64(uint64(d.r.readn1()))
	case mpUint16:
		i = int64(uint64(bigen.Uint16(d.r.readx(2))))
	case mpUint32:
		i = int64(uint64(bigen.Uint32(d.r.readx(4))))
	case mpUint64:
		i = int64(bigen.Uint64(d.r.readx(8)))
	case mpInt8:
		i = int64(int8(d.r.readn1()))
	case mpInt16:
		i = int64(int16(bigen.Uint16(d.r.readx(2))))
	case mpInt32:
		i = int64(int32(bigen.Uint32(d.r.readx(4))))
	case mpInt64:
		i = int64(bigen.Uint64(d.r.readx(8)))
	default:
		switch {
		case d.bd >= mpPosFixNumMin && d.bd <= mpPosFixNumMax:
			i = int64(int8(d.bd))
		case d.bd >= mpNegFixNumMin && d.bd <= mpNegFixNumMax:
			i = int64(int8(d.bd))
		default:
			d.d.errorf("cannot decode signed integer: %s: %x/%s", msgBadDesc, d.bd, mpdesc(d.bd))
			return
		}
	}
	d.bdRead = false
	return
}
116319
func (vb *packer) WriteUint64(num uint64) (int, error) {
	binary.BigEndian.PutUint64(vb.tempBuffer[:8], num)
	vb.Write(vb.tempBuffer[:8])
	return 8, nil
}
215529
func (c *Config) GetUint64(key string) (u uint64, err error) {
	val, ok := (*c)[key]
	if !ok {
		return 0, ErrNoSuchKey
	}
	switch val.(type) {
	case uint8:
		return uint64(val.(uint8)), nil
	case uint16:
		return uint64(val.(uint16)), nil
	case uint32:
		return uint64(val.(uint32)), nil
	case uint:
		return uint64(val.(uint)), nil
	case uint64:
		return val.(uint64), nil
	case float64:
		// json loads float64 so handle that case
		return uint64(val.(float64)), nil
	default:
		return 0, fmt.Errorf("Wrong type for %s (Type:%T Expecting:%T)", key, val, u)
	}
}
355239
func base64Decode(b []byte) []byte {
	n, _ := base64.StdEncoding.Decode(b, b)
	return b[:n]
}
556343
func (p *Buffer) DecodeZigzag64() (x uint64, err error) {
	x, err = p.DecodeVarint()
	if err != nil {
		return
	}
	x = (x >> 1) ^ uint64((int64(x&1)<<63)>>63)
	return
}
1145323
func DecodeOrderPreservingVarUint64(bytes []byte) (uint64, int) {
	s, _ := proto.DecodeVarint(bytes)
	size := int(s)
	decodedBytes := make([]byte, 8)
	copy(decodedBytes[8-size:], bytes[1:size+1])
	numBytesConsumed := size + 1
	return binary.BigEndian.Uint64(decodedBytes), numBytesConsumed
}
1199141
func parseUint(s string, base, bitSize int) (uint64, error) {
	value, err := strconv.ParseUint(s, base, bitSize)
	if err != nil {
		intValue, intErr := strconv.ParseInt(s, base, bitSize)
		// 1. Handle negative values greater than MinInt64 (and)
		// 2. Handle negative values lesser than MinInt64
		if intErr == nil && intValue < 0 {
			return 0, nil
		} else if intErr != nil && intErr.(*strconv.NumError).Err == strconv.ErrRange && intValue < 0 {
			return 0, nil
		}

		return value, err
	}

	return value, nil
}
757961
func (c *Context) GlobalUint64(name string) uint64 {
	if fs := lookupGlobalFlagSet(name, c); fs != nil {
		return lookupUint64(name, fs)
	}
	return 0
}
574376
func decodeUint16(b []byte) (uint16, error) {
	// Check the length of the slice of bytes.
	if len(b) != 2 {
		return 0, ErrInvalidByteLen
	}

	return uint16(b[0])<<8 | uint16(b[1]), nil
}
1373116
func deinterleaveUint32(code uint64) (uint32, uint32) {
	x := (deinterleaveLookup[code&0x55]) |
		(deinterleaveLookup[(code>>8)&0x55] << 4) |
		(deinterleaveLookup[(code>>16)&0x55] << 8) |
		(deinterleaveLookup[(code>>24)&0x55] << 12) |
		(deinterleaveLookup[(code>>32)&0x55] << 16) |
		(deinterleaveLookup[(code>>40)&0x55] << 20) |
		(deinterleaveLookup[(code>>48)&0x55] << 24) |
		(deinterleaveLookup[(code>>56)&0x55] << 28)
	y := (deinterleaveLookup[code&0xaa]) |
		(deinterleaveLookup[(code>>8)&0xaa] << 4) |
		(deinterleaveLookup[(code>>16)&0xaa] << 8) |
		(deinterleaveLookup[(code>>24)&0xaa] << 12) |
		(deinterleaveLookup[(code>>32)&0xaa] << 16) |
		(deinterleaveLookup[(code>>40)&0xaa] << 20) |
		(deinterleaveLookup[(code>>48)&0xaa] << 24) |
		(deinterleaveLookup[(code>>56)&0xaa] << 28)
	return x, y
}
739777
func DecodeUint64(input string) (uint64, error) {
	raw, err := checkNumber(input)
	if err != nil {
		return 0, err
	}
	dec, err := strconv.ParseUint(raw, 16, 64)
	if err != nil {
		err = mapError(err)
	}
	return dec, err
}
996641
func FromUint64(data [8]byte) uint64 {
	ui64 := binary.LittleEndian.Uint64(data[:])
	return ui64
}
1228610
func MustParseUint64(s string) uint64 {
	v, ok := ParseUint64(s)
	if !ok {
		panic("invalid unsigned 64 bit integer: " + s)
	}
	return v
}
896486
func DecodeUints(s string) ([]uint, error) {
	xs := make([]uint, 0)
	var x, shift uint
	for i, c := range []byte(s) {
		switch {
		case 63 <= c && c < 95:
			xs = append(xs, x+(uint(c)-63)<<shift)
			x = 0
			shift = 0
		case 95 <= c && c < 127:
			x += (uint(c) - 95) << shift
			shift += 5
		default:
			return nil, &InvalidCharacterError{i, c}
		}
	}
	if shift != 0 {
		return nil, &UnterminatedError{}
	}
	return xs, nil
}
342808
func (e *Encoding) DecodeToInt64(s string) int64 {
	var (
		n     int64
		c     int64
		idx   int
		power int
	)

	for i, v := range s {
		idx = strings.IndexRune(e.encode, v)

		// Work downwards through powers of our base
		power = len(s) - (i + 1)

		// Calculate value at this position and add
		c = int64(idx) * int64(math.Pow(float64(base), float64(power)))
		n = n + c
	}

	return int64(n)
}
636514
func (d *defaulter) AsUint64(v Valuer, dv uint64) uint64 {
	value, err := v.Value()
	if err != nil {
		d.logValuerError(err)
		return dv
	}
	uivalue, err := strconv.ParseUint(value, 10, 64)
	if err != nil {
		d.logFormatError("uint64", err)
		return dv
	}
	return uint64(uivalue)
}