aboutsummaryrefslogtreecommitdiff
path: root/internal/intconv/se_u8_u32.go
blob: bef34268785da273c6497e63eab9cabf19807403 (about) (plain) (blame)
1
2
3
4
5
6
7
8
9
10
package intconv

// SignExtendByteToUint32 sign-extends b as a signed 8-bit integer into uint32.
func SignExtendByteToUint32(b byte) uint32 {
	if b&0x80 == 0 {
		return uint32(b)
	}

	return 0xFFFFFF00 | uint32(b)
}