Course of Raku / Addendum 🆕 / Working with data / Numbers and mathematics / Exercises / One number, three bases
Solution: One number, three bases
Here is a possible solution to the task.
Code
my $n = 255;
say $n.base(2);
say $n.base(8);
say $n.base(16);🦋 You can find the source code in the file number-bases.raku.
Output
11111111
377
FFComments
- The
.basemethod renders an integer in any base from 2 to 36, returning a string.255is11111111in binary andFFin hexadecimal — the largest value that fits in one byte.