On Tue, Mar 23, 2010 at 12:07 PM, Daniel Bünzli
<daniel.buen...@erratique.ch> wrote:
>> let round x = truncate (x +. 0.5)
>
> Side note, if you are also interested in negative numbers

Sure, it was just an code generation example. Probably I should use
round_positive name.

> that's not what you want. You want :
>
>> let round x = floor (x +. 0.5)

...and you get a floor() C call. I would better use

let round x = truncate (x +. (if x > 0. then 0.5 else -0.5))

- Dmitry Bely

_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Reply via email to