Integer.Extension (ESpec v1.10.0)

View Source

A module to extend the calendar implementation that follows to ISO8601 with methods found in Elixir 1.5.1. This is to allow ESpec to support Elixir >= 1.3.4 more easily.

Summary

Functions

Performs a floored integer division.

Functions

floor_div(dividend, divisor)

@spec floor_div(integer(), neg_integer() | pos_integer()) :: integer()

Performs a floored integer division.

Raises an ArithmeticError exception if one of the arguments is not an integer, or when the divisor is 0.

Integer.floor_div/2 performs floored integer division. This means that the result is always rounded towards negative infinity.

If you want to perform truncated integer division (rounding towards zero), use Kernel.div/2 instead.

Examples

iex> Integer.floor_div(5, 2)
2
iex> Integer.floor_div(6, -4)
-2
iex> Integer.floor_div(-99, 2)
-50