# with non-integer result
>> half_days = 3
=> 3
>> days = half_days / 2.0
=> 1.5
>> format('%g', days)
=> 1.5
# with whole number result
>> half_days = 4
=> 4
>> days = half_days / 2.0
=> 2.0
>> format('%g', days)
=> 2
Last active
October 31, 2016 11:27
-
-
Save francois-blanchard/3c14fd580132cfc10ca930869738a8c0 to your computer and use it in GitHub Desktop.
[ruby] How to round float number when it's a whole number
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment