Where x
is any integer, I have a value about x.1..x.4
. I want to round it to x.5
, and if it is above x.5
, say x.7
or x.8
, then it should round to (x+1).0
. How is that possible? Is there a function in ruby?
Asked
Active
Viewed 1,494 times
1 Answers
10
-
6(v*2).ceil.to_f / 2 => (v*2).ceil / 2.0 – CodeGroover Oct 05 '13 at 13:29
-
2@CodeGroover Whether to adopt your idea is up to mrd abd. If mrd abd wants to adopt that, then mrd abd will do so. Do not change the code in other peoples answer (other than for trivial things like formatting, removing extra part, etc.). – sawa Oct 05 '13 at 13:37