[erlang-questions] math ceil floor

Samuel samuelrivas@REDACTED
Fri Jun 3 23:37:48 CEST 2016


>> I made pull request https://github.com/erlang/otp/pull/1084which
>> implements ceil and floor in the math module.
>>
>> The question is, should they return integer or floats?
>
>
> Yes, they should.  For each of floor, ceiling, round, truncate there are
> two sensible functions: one returns the appropriate integer as an integer,
> and the other returns it as a floating-point number.

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

Since Erlang has bignums, which I understand can represent the integer
part of any float,  and those operations are supposed to return an
integer I can't see a reason for a float result (other than, maybe,
performance).

Best
-- 
Samuel



More information about the erlang-questions mailing list