[erlang-questions] 答复: math ceil floor
Zhengji Li
foldl@REDACTED
Fri Jun 3 06:05:07 CEST 2016
IMHO, ceil/floor should return integers when we have big-integers. In C, to avoid overflow, they have to return floating point numbers.
IMHO, I don’t think we need ffloor/fround.
Mathematica can be taken as an example.
Best regards,
Li Zhengji
发件人: Richard A. O'Keefe<mailto:ok@REDACTED>
发送时间: 2016年6月3日 11:36
收件人: erlang-questions@REDACTED<mailto:erlang-questions@REDACTED>
主题: Re: [erlang-questions] math ceil floor
On 3/06/16 10:42 AM, Technion wrote:
>
> Following from other languages, C's ceil returns floats, but Ruby's
> ceil returns an Integer, PHP returns a float.
>
>
> I'm seeing here there isn't a particularly accepted standard.
>
Let's put that another way.
C's library is defective in only offering truncation to integer (via (int))
and rounding (via l[l]rint{f,,l}()), no int-valued floor or ceiling.
Ruby's Float class is defective in only offering conversion to integer,
not float-valued ceiling &c (Float.round can be persuaded to return a
float, but not when you want it to be integral, which is both absurd and
painfully typical of Ruby).
PHP is, well, PHP.
If, on the other hand, we turn to other languages,
we learn that Lisp has {f,}(round,floor,ceiling,truncate)
and ML has realFloor, realCeil, realTrunc, realRound and
floor, ceil, trunc, round, 8 functions, not 4.
(The REAL signature, section 11.50 of The Standard
ML Basis Library.)
So there is prior art for providing *both*, with the simple name
delivering an integer, and the prefixed name returning float.
_______________________________________________
erlang-questions mailing list
erlang-questions@REDACTED
http://erlang.org/mailman/listinfo/erlang-questions
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20160603/f9450b56/attachment.htm>
More information about the erlang-questions
mailing list