bcd

package
v0.0.0-...-8b88f26 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 19, 2020 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package bcd provides functions for converting integers to BCD byte array and vice versa.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromUint

func FromUint(value uint64, size int) []byte

FromUint ...

func FromUint16

func FromUint16(value uint16) []byte

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

func FromUint32(value uint32) []byte

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

func FromUint64(value uint64) []byte

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 FromUint8

func FromUint8(value uint8) byte

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 ToUint16

func ToUint16(value []byte) uint16

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.

func ToUint32

func ToUint32(value []byte) uint32

ToUint32 Return uint32 value converted from at most last four bytes of bcd bytes array.

If any byte of used array part is not BCD (e.g 0x1A), function returns zero.

func ToUint64

func ToUint64(value []byte) uint64

ToUint64 Return uint64 value converted from at most last eight bytes of bcd bytes array.

If any byte of used array part is not BCD (e.g 0x1A), function returns zero.

func ToUint8

func ToUint8(value byte) uint8

ToUint8 Returns uint8 value converted from bcd byte.

If byte is not BCD (e.g. 0x1A), function returns zero.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL