package msgpack

import (
	
	

	
)

// EncodeUint8 encodes an uint8 in 2 bytes preserving type of the number.
func ( *Encoder) ( uint8) error {
	return .write1(msgpcode.Uint8, )
}

func ( *Encoder) ( uint8) error {
	if .flags&useCompactIntsFlag != 0 {
		return .EncodeUint(uint64())
	}
	return .EncodeUint8()
}

// EncodeUint16 encodes an uint16 in 3 bytes preserving type of the number.
func ( *Encoder) ( uint16) error {
	return .write2(msgpcode.Uint16, )
}

func ( *Encoder) ( uint16) error {
	if .flags&useCompactIntsFlag != 0 {
		return .EncodeUint(uint64())
	}
	return .EncodeUint16()
}

// EncodeUint32 encodes an uint16 in 5 bytes preserving type of the number.
func ( *Encoder) ( uint32) error {
	return .write4(msgpcode.Uint32, )
}

func ( *Encoder) ( uint32) error {
	if .flags&useCompactIntsFlag != 0 {
		return .EncodeUint(uint64())
	}
	return .EncodeUint32()
}

// EncodeUint64 encodes an uint16 in 9 bytes preserving type of the number.
func ( *Encoder) ( uint64) error {
	return .write8(msgpcode.Uint64, )
}

func ( *Encoder) ( uint64) error {
	if .flags&useCompactIntsFlag != 0 {
		return .EncodeUint()
	}
	return .EncodeUint64()
}

// EncodeInt8 encodes an int8 in 2 bytes preserving type of the number.
func ( *Encoder) ( int8) error {
	return .write1(msgpcode.Int8, uint8())
}

func ( *Encoder) ( int8) error {
	if .flags&useCompactIntsFlag != 0 {
		return .EncodeInt(int64())
	}
	return .EncodeInt8()
}

// EncodeInt16 encodes an int16 in 3 bytes preserving type of the number.
func ( *Encoder) ( int16) error {
	return .write2(msgpcode.Int16, uint16())
}

func ( *Encoder) ( int16) error {
	if .flags&useCompactIntsFlag != 0 {
		return .EncodeInt(int64())
	}
	return .EncodeInt16()
}

// EncodeInt32 encodes an int32 in 5 bytes preserving type of the number.
func ( *Encoder) ( int32) error {
	return .write4(msgpcode.Int32, uint32())
}

func ( *Encoder) ( int32) error {
	if .flags&useCompactIntsFlag != 0 {
		return .EncodeInt(int64())
	}
	return .EncodeInt32()
}

// EncodeInt64 encodes an int64 in 9 bytes preserving type of the number.
func ( *Encoder) ( int64) error {
	return .write8(msgpcode.Int64, uint64())
}

func ( *Encoder) ( int64) error {
	if .flags&useCompactIntsFlag != 0 {
		return .EncodeInt()
	}
	return .EncodeInt64()
}

// EncodeUnsignedNumber encodes an uint64 in 1, 2, 3, 5, or 9 bytes.
// Type of the number is lost during encoding.
func ( *Encoder) ( uint64) error {
	if  <= math.MaxInt8 {
		return .w.WriteByte(byte())
	}
	if  <= math.MaxUint8 {
		return .EncodeUint8(uint8())
	}
	if  <= math.MaxUint16 {
		return .EncodeUint16(uint16())
	}
	if  <= math.MaxUint32 {
		return .EncodeUint32(uint32())
	}
	return .EncodeUint64()
}

// EncodeNumber encodes an int64 in 1, 2, 3, 5, or 9 bytes.
// Type of the number is lost during encoding.
func ( *Encoder) ( int64) error {
	if  >= 0 {
		return .EncodeUint(uint64())
	}
	if  >= int64(int8(msgpcode.NegFixedNumLow)) {
		return .w.WriteByte(byte())
	}
	if  >= math.MinInt8 {
		return .EncodeInt8(int8())
	}
	if  >= math.MinInt16 {
		return .EncodeInt16(int16())
	}
	if  >= math.MinInt32 {
		return .EncodeInt32(int32())
	}
	return .EncodeInt64()
}

func ( *Encoder) ( float32) error {
	if .flags&useCompactFloatsFlag != 0 {
		if float32(int64()) ==  {
			return .EncodeInt(int64())
		}
	}
	return .write4(msgpcode.Float, math.Float32bits())
}

func ( *Encoder) ( float64) error {
	if .flags&useCompactFloatsFlag != 0 {
		// Both NaN and Inf convert to int64(-0x8000000000000000)
		// If n is NaN then it never compares true with any other value
		// If n is Inf then it doesn't convert from int64 back to +/-Inf
		// In both cases the comparison works.
		if float64(int64()) ==  {
			return .EncodeInt(int64())
		}
	}
	return .write8(msgpcode.Double, math.Float64bits())
}

func ( *Encoder) ( byte,  uint8) error {
	.buf = .buf[:2]
	.buf[0] = 
	.buf[1] = 
	return .write(.buf)
}

func ( *Encoder) ( byte,  uint16) error {
	.buf = .buf[:3]
	.buf[0] = 
	.buf[1] = byte( >> 8)
	.buf[2] = byte()
	return .write(.buf)
}

func ( *Encoder) ( byte,  uint32) error {
	.buf = .buf[:5]
	.buf[0] = 
	.buf[1] = byte( >> 24)
	.buf[2] = byte( >> 16)
	.buf[3] = byte( >> 8)
	.buf[4] = byte()
	return .write(.buf)
}

func ( *Encoder) ( byte,  uint64) error {
	.buf = .buf[:9]
	.buf[0] = 
	.buf[1] = byte( >> 56)
	.buf[2] = byte( >> 48)
	.buf[3] = byte( >> 40)
	.buf[4] = byte( >> 32)
	.buf[5] = byte( >> 24)
	.buf[6] = byte( >> 16)
	.buf[7] = byte( >> 8)
	.buf[8] = byte()
	return .write(.buf)
}

func ( *Encoder,  reflect.Value) error {
	return .EncodeUint(.Uint())
}

func ( *Encoder,  reflect.Value) error {
	return .EncodeInt(.Int())
}

func ( *Encoder,  reflect.Value) error {
	return .encodeUint8Cond(uint8(.Uint()))
}

func ( *Encoder,  reflect.Value) error {
	return .encodeUint16Cond(uint16(.Uint()))
}

func ( *Encoder,  reflect.Value) error {
	return .encodeUint32Cond(uint32(.Uint()))
}

func ( *Encoder,  reflect.Value) error {
	return .encodeUint64Cond(.Uint())
}

func ( *Encoder,  reflect.Value) error {
	return .encodeInt8Cond(int8(.Int()))
}

func ( *Encoder,  reflect.Value) error {
	return .encodeInt16Cond(int16(.Int()))
}

func ( *Encoder,  reflect.Value) error {
	return .encodeInt32Cond(int32(.Int()))
}

func ( *Encoder,  reflect.Value) error {
	return .encodeInt64Cond(.Int())
}

func ( *Encoder,  reflect.Value) error {
	return .EncodeFloat32(float32(.Float()))
}

func ( *Encoder,  reflect.Value) error {
	return .EncodeFloat64(.Float())
}