links: [[Elixir MOC]]
---
# About Floating point numbers
Floats are numbers with one or more digits behind the decimal separator. They use the 64-bit double-precision floating-point format
```elixir
float = 3.45
# => 3.45
```
## Working with numbers
In the **Integer** and **Float** modules, you can find some useful functions for working with those types. Basic arithmetic operators are defined in the **Kernel** module
## Conversion
Integers and Floats can be mixed in a single arithmetic expression. Using a float in an expression ensures the result will be a float too
```elixir
2 * 3
# => 6
2 * 3.0
# => 6.0
```
However, when doing division, the result will always be a float, even if integers are only used
```elixir
6 / 2
# => 3.0
```
To convert a float to an integer you can discard the decimal part with [`trunc/1`](https://hexdocs.pm/elixir/Kernel.html#trunc/1)
---
tags: #elixir #floating-point
sources:
- [Float Module](https://hexdocs.pm/elixir/Float.html)
- https://0.30000000000000004.com