it seems ruby chooses round negative numbers down instead of closer zero.
-1.5.round #=>-2 whereas positive numbers work other way:
2.5.round #=>3 how round negative numbers(closer zero) instead of rounding them down? i'm using ruby version 2.2.2.
this should work.
> (-1.5+0.5).floor => -1 > (-1.4+0.5).floor => -1 > (-1.6+0.5).floor => -2
Comments
Post a Comment