Course of Raku / Essentials / Variables and data types essentials / Numbers
Integer numbers
The Int data type represents integer numbers. Numbers
can be positive and negative, and you can use an explicit +
sign if you want to. Here are a few obvious examples:
42
-42
100
-5
0Yes, a bare 0 is considered an integer by default.
Groups of digits
Raku has a cute feature that lets you spell big numbers with some visual helpers that split the digits into groups of thousands:
1_000_000
-3_141_592Although you can construct a number such as 34_56, you’d
better avoid it as this may confuse other people reading your code. But
you cannot have two adjacent underscores, nor can you start or end the
number with it.
Arbitrary long integers
Raku perfectly handles the numbers beyond the 32- or 64-bit limits. For example, the following program is an acceptable program that multiplies two big integer numbers and prints the correct result.
say 1_234_456_789_012_345_678_901 * 987_654_321_098_765_432_100;Practice
Complete the quizzes that cover the contents of this topic.
Course navigation
← Numbers | Quiz: Integer numbers →
💪 Or jump directly to
the exercises in this section.
Translations of this page: English • Deutsch • Español • Italiano • Latviešu • Nederlands • Български • Русский • Українська