Documentation
¶
Overview ¶
Package bcd provides functions for converting integers to BCD byte array and vice versa.
Index ¶
- func FromUint(value uint64, size int) []byte
- func FromUint8(value uint8) byte
- func FromUint16(value uint16) []byte
- func FromUint32(value uint32) []byte
- func FromUint64(value uint64) []byte
- func ToUint8(value byte) uint8
- func ToUint16(value []byte) uint16
- func ToUint32(value []byte) uint32
- func ToUint64(value []byte) uint64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FromUint8 ¶
FromUint8 Returns uint8 value in BCD format.
If value > 99, function returns value for last two digits of source value (Example: uint8(123) = uint8(0x23)).
func FromUint16 ¶
FromUint16 Returns two-bytes array with uint16 value in BCD format
If value > 9999, function returns value for last two digits of source value (Example: uint8(12345) = []byte{0x23, 0x45}).
func FromUint32 ¶
FromUint32 Returns four-bytes array with uint32 value in BCD format
If value > 99999999, function returns value for last two digits of source value (Example: uint8(1234567890) = []byte{0x23, 0x45, 0x67, 0x89}).
func FromUint64 ¶
FromUint64 Returns eight-bytes array with uint64 value in BCD format
If value > 9999999999999999, function returns value for last two digits of source value (Example: uint8(12233445566778899) = []byte{0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99}).
func ToUint8 ¶
ToUint8 Returns uint8 value converted from bcd byte.
If byte is not BCD (e.g. 0x1A), function returns zero.
func ToUint16 ¶
ToUint16 Return uint16 value converted from at most last two bytes of bcd bytes array.
If any byte of used array part is not BCD (e.g 0x1A), function returns zero.
Types ¶
This section is empty.