[erlang-questions] Flooring integer division in Erlang?

Dimitry Golubovsky <>
Sat Apr 26 17:49:08 CEST 2008


Hi,

Is there any Erlang library around that contains an integer division
function that rounds negative quotient down (towards negative
infunity, flooring division)?

I am trying to implement Haskell-style division which for

(-5) `div` (3) yields -2

while Erlang's (-5) div (3) yields -1

Thanks.

PS The Erlang specification (rather old, of 1999
http://www.erlang.org/download/erl_spec47.ps.gz), mentions on page 15
that at some moment, operations // and mod were added, which round to
negative infinity (as oposite to div and rem). Were these ever
implemented?

-- 
Dimitry Golubovsky

Anywhere on the Web



More information about the erlang-questions mailing list