Course of Raku / Advanced / More about built-in types / Native types 🆕 / Sized types and overflow

Quiz — Overflow

What does the following program print?

my int8 $i = -128;
$i--;
say $i;
1127
0-129
0-128
00

An int8 holds values from -128 to 127. Wrapping happens at the bottom edge too: decrementing the smallest value cannot give -129, so it folds around to the largest value, 127.

Course navigation

Sized types and overflow   |   The native default