EncodeNumber encodes an int64 in 1, 2, 3, 5, or 9 bytes. Type of the number is lost during encoding.
(n int64)
| 124 | // EncodeNumber encodes an int64 in 1, 2, 3, 5, or 9 bytes. |
| 125 | // Type of the number is lost during encoding. |
| 126 | func (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 | |
| 145 | func (e *Encoder) EncodeFloat32(n float32) error { |
| 146 | if e.flags&useCompactFloatsFlag != 0 { |
no test coverage detected