FILE / ScuroNeko/mtg

_utils/uint24.go

Исходный файл и его история в репозитории.
FILE d459efcf9cc12f3ae1902b4efe3fae71d6b8c225
Files
mtg/_utils/uint24.go
T
2019-09-04 10:19:01 +03:00

16 lines
447 B
Go

package utils
// Uint24 is a replacement for the absent Go uint24 data type.
// This data type is little endian.
type Uint24 [3]byte
// ToUint24 converts number to Uint24.
func ToUint24(number uint32) Uint24 {
return Uint24{byte(number), byte(number >> 8), byte(number >> 16)}
}
// FromUint24 converts Uint24 to number.
func FromUint24(number Uint24) uint32 {
return uint32(number[0]) + (uint32(number[1]) << 8) + (uint32(number[2]) << 16)
}