Running ruby 1.8.7.
(1.005 * 100).round
result: 100
(1.006 * 100).round
result: 101
100.5.round
result: 101
(1.005 * 100)
result: 100.5
What is going on here? Can someone try this in the latest version of ruby please?
Thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Floating Point Math is what’s going on.
For the last one, I do not get 100.5, and you aren’t either, even if for some reason it’s displaying as that: