MCPcopy Create free account
hub / github.com/DOSNetwork/core / LittleEndian

Method LittleEndian

group/mod/int.go:391–408  ·  view source on GitHub ↗

LittleEndian encodes the value of this Int into a little-endian byte-slice at least min bytes but no more than max bytes long. Panics if max != 0 and the Int cannot be represented in max bytes.

(min, max int)

Source from the content-addressed store, hash-verified

389// at least min bytes but no more than max bytes long.
390// Panics if max != 0 and the Int cannot be represented in max bytes.
391func (i *Int) LittleEndian(min, max int) []byte {
392 act := i.MarshalSize()
393 vBytes := i.V.Bytes()
394 vSize := len(vBytes)
395 if vSize < act {
396 act = vSize
397 }
398 pad := act
399 if pad < min {
400 pad = min
401 }
402 if max != 0 && pad > max {
403 panic("Int not representable in max bytes")
404 }
405 buf := make([]byte, pad)
406 reverse(buf[:act], vBytes)
407 return buf
408}
409
410// HideLen returns the length in bytes of a uniform byte-string encoding of this Int,
411// satisfying the requirements of the Hiding interface.

Callers 4

MarshalBinaryMethod · 0.95
setIntMethod · 0.80
TestIntEndiannessFunction · 0.80
TestIntEndianBytesFunction · 0.80

Calls 2

MarshalSizeMethod · 0.95
reverseFunction · 0.85

Tested by 2

TestIntEndiannessFunction · 0.64
TestIntEndianBytesFunction · 0.64