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-23427
are 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#00101010
or 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
$C
represents the integer code ...
Get Programming Erlang, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.