Category: Keywords
Syntax:
ShrU:Int()
Int
Logical (unsigned) shift right operator - shifts bits right, filling with zeros.
Syntax is value ShrU count. Shifts the 32 bits of the value right by count positions and fills the top with zeros, so the result is never negative for a count of 1 or more: -1 ShrU 28 is 15. Shr instead copies the sign bit down (an arithmetic shift), so -1 Shr 28 is still -1.
Use ShrU to pull fields out of a full 32-bit value (colours, packed data, CPU instructions in an emulator) without masking off the sign afterwards. The count is taken modulo 32 (0 to 31), as the CPU does.
View detailed documentation online
Local colour:Int = $FF8040C0 Print colour ShrU 24 ; 255 (the alpha) - Shr would give -1 Print (colour ShrU 16) BitAnd 255 ; 128 (the red)
BambooBasic © 2026 Michael Denathorn