TL;DR
Let’s see how Elixir handles numbers. This post is part of the functional language series, and it is based on the remarkable book Elixir In Action by Sasa Juric.
Let’s start iex
and try out numbers from the image above. Integer numbers could be represented using hexadecimal notation. Knowing hexadecimal numbers is a precondition to be a programmer. Then we used decimal notation for the same amount, 174
You can also use exponential notation that is useful for representing very large or small numbers. Division operator always returns float
and Kernel
module has some mathematical operations. You can use handy notation with _
where you use it to denote thousands for large quantities.
Remember
- Number types are integer and float
- You can use hexadecimal and exponential notation
/
always returns float- you can use
_
in integers - Kernel autoloaded library implements some mathematical functions
- There is no upper size limit for integers.