Basic Calculations

Let’s have a look at some basic calculations with the types integer (integer numbers) and float (real numbers):

iex> 1 + 1
2
iex> 1.1 + 1
2.1
iex> 23 / 3
7.666666666666667

You can use the i/1 function which is build into the iex shell to find out the type of an expression. I like to combine that with the v/1 function which prints the value of the latest expression.

iex> 23 / 3
7.666666666666667
iex> i v
Term
  7.666666666666667
Data type
  Float
Reference modules
  Float
Implemented protocols
  IEx.Info, Inspect, JSON.Encoder, List.Chars, String.Chars