[erlang-questions] Floor Function?

Hynek Vychodil vychodil.hynek@REDACTED
Mon Mar 16 12:44:25 CET 2009


On Mon, Mar 16, 2009 at 5:10 AM, Richard O'Keefe <ok@REDACTED> wrote:

>
> On 14 Mar 2009, at 7:17 am, Bob Ippolito wrote:
> > int_ceil(X) ->
> >    T = trunc(X),
> >    case (X - T) of
> >        Neg when Neg < 0 -> T;
> >        Pos when Pos > 0 -> T + 1;
> >        _ -> T
> >    end.
>
> Why isn't this
>
> int_ceil(X) ->
>     T = trunc(X),
>      if X > T -> T + 1
>      ; true  -> T
>     end.
>
> int_floor(X) ->
>     T = trunc(X),
>     if X < T -> T - 1
>      ; true  -> T
>     end.
>
> There doesn't seem to be any reason to compute X-T.
>

Are you sure that there is big difference between compute X-T and decide X<T
or which one is less expensive? I'm not! If you haven't measured ...

>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>



-- 
--Hynek (Pichi) Vychodil

Analyze your data in minutes. Share your insights instantly. Thrill your
boss.  Be a data hero!
Try Good Data now for free: www.gooddata.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20090316/0fe2c82e/attachment.htm>


More information about the erlang-questions mailing list