From 62fbc4171726aee53bf0ba99f24b02d7238e107f Mon Sep 17 00:00:00 2001 From: Charles Iliya Krempeaux Date: Sat, 28 Oct 2023 13:22:58 -0700 Subject: [PATCH] initial commits --- bytes/encodeint8.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 bytes/encodeint8.go diff --git a/bytes/encodeint8.go b/bytes/encodeint8.go new file mode 100644 index 0000000..b973d53 --- /dev/null +++ b/bytes/encodeint8.go @@ -0,0 +1,22 @@ +package hexadecabytes + +import ( + "sourcecode.social/reiver/go-hexadeca/symbols/byte" +) + +// EncodeInt8 encodes the value of a int8 into hexadecimal. +func EncodeInt8(value int8, symbolFunc func(byte)byte) (mostSignificant byte, leastSignificant byte) { + + mostSignificant = symbolFunc( byte(0x0f & (value >> 4)) ) + leastSignificant = symbolFunc( byte(0x0f & (value )) ) + + return +} + +func EncodeInt8UsingLowerCaseSymbols(value int8) (mostSignificant byte, leastSignificant byte) { + return EncodeInt8(value, bytesymbols.LowerCase) +} + +func EncodeInt8UsingUpperCaseSymbols(value int8) (mostSignificant byte, leastSignificant byte) { + return EncodeInt8(value, bytesymbols.UpperCase) +}