MCPcopy Index your code
hub / github.com/vmihailenco/msgpack / EncodeInt

Method EncodeInt

encode_number.go:126–143  ·  view source on GitHub ↗

EncodeNumber encodes an int64 in 1, 2, 3, 5, or 9 bytes. Type of the number is lost during encoding.

(n int64)

Source from the content-addressed store, hash-verified

124// EncodeNumber encodes an int64 in 1, 2, 3, 5, or 9 bytes.
125// Type of the number is lost during encoding.
126func (e *Encoder) EncodeInt(n int64) error {
127 if n >= 0 {
128 return e.EncodeUint(uint64(n))
129 }
130 if n >= int64(int8(msgpcode.NegFixedNumLow)) {
131 return e.w.WriteByte(byte(n))
132 }
133 if n >= math.MinInt8 {
134 return e.EncodeInt8(int8(n))
135 }
136 if n >= math.MinInt16 {
137 return e.EncodeInt16(int16(n))
138 }
139 if n >= math.MinInt32 {
140 return e.EncodeInt32(int32(n))
141 }
142 return e.EncodeInt64(n)
143}
144
145func (e *Encoder) EncodeFloat32(n float32) error {
146 if e.flags&useCompactFloatsFlag != 0 {

Callers 9

encodeInt8CondMethod · 0.95
encodeInt16CondMethod · 0.95
encodeInt32CondMethod · 0.95
encodeInt64CondMethod · 0.95
EncodeFloat32Method · 0.95
EncodeFloat64Method · 0.95
EncodeMethod · 0.95
EncodeDurationMethod · 0.95
encodeIntValueFunction · 0.80

Calls 6

EncodeUintMethod · 0.95
EncodeInt8Method · 0.95
EncodeInt16Method · 0.95
EncodeInt32Method · 0.95
EncodeInt64Method · 0.95
WriteByteMethod · 0.65

Tested by

no test coverage detected