[erlang-questions] math ceil floor

Valentin Nechayev <>
Fri Sep 2 16:56:40 CEST 2016


 Fri, Jun 03, 2016 at 23:37:48, samuelrivas wrote about "Re: [erlang-questions] math ceil floor": 

> What is the use case when you want floor/ceil to return a float and
> not an integer in Erlang?

C provides floor() and ceil() according to IEEE754 that requires

* sourceFormat roundToIntegralTowardPositive(source)
* sourceFormat roundToIntegralTowardNegative(source)

format isn't changed. So, operations with float result will be direct
mapping of those of implementation, with all consequential features,
as efficiency.

A variant of conversion of the result to integer will be as efficient
as explicit conversion after math library floor/ceil, except a cost to chain
two Erlang calls.


-netch-


More information about the erlang-questions mailing list