EncodeUnsignedNumber encodes an uint64 in 1, 2, 3, 5, or 9 bytes. Type of the number is lost during encoding.
(n uint64)
| 106 | // EncodeUnsignedNumber encodes an uint64 in 1, 2, 3, 5, or 9 bytes. |
| 107 | // Type of the number is lost during encoding. |
| 108 | func (e *Encoder) EncodeUint(n uint64) error { |
| 109 | if n <= math.MaxInt8 { |
| 110 | return e.w.WriteByte(byte(n)) |
| 111 | } |
| 112 | if n <= math.MaxUint8 { |
| 113 | return e.EncodeUint8(uint8(n)) |
| 114 | } |
| 115 | if n <= math.MaxUint16 { |
| 116 | return e.EncodeUint16(uint16(n)) |
| 117 | } |
| 118 | if n <= math.MaxUint32 { |
| 119 | return e.EncodeUint32(uint32(n)) |
| 120 | } |
| 121 | return e.EncodeUint64(n) |
| 122 | } |
| 123 | |
| 124 | // EncodeNumber encodes an int64 in 1, 2, 3, 5, or 9 bytes. |
| 125 | // Type of the number is lost during encoding. |
no test coverage detected