[erlang-questions] math ceil floor

Dmitry Belyaev be.dmitry@REDACTED
Sun Sep 4 10:35:44 CEST 2016


Another possibility would be to return the argument if it is already an integer. It would be convenient for long integers as no loss of precision would come from conversion to a float. 

On 3 September 2016 00:56:40 GMT+10:00, Valentin Nechayev <netch@REDACTED> wrote:
>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-
>_______________________________________________
>erlang-questions mailing list
>erlang-questions@REDACTED
>http://erlang.org/mailman/listinfo/erlang-questions

-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20160904/dd93e642/attachment.htm>


More information about the erlang-questions mailing list