Numbers
Numbers in Erlang are either integers or floats.
Integers
Integer arithmetic is exact, and the number of digits that can be represented in an integer is limited only by available memory.
Integers are written with one of three different syntaxes.
- Conventional syntax
-
Here integers are written as you expect. For example,
12,12375, and-23427are all integers. - Base K integers
-
Integers in a number base other than ten are written with the syntax
K#Digits; thus, we can write a number in binary as2#00101010or a number in hexadecimal as16#af6bfa23. For bases greater than ten, the charactersabc...(orABC...) represent the numbers10,11,12, and so on. The highest number base is 36. - $ syntax
-
The syntax
$Crepresents the integer code ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access