I’m trying to round a float value as follows:
(0.11 + 0.22 + 0.23 / 3).round(2)
Does anyone know if there is other effective way to round up?
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.
If you always want to round up and never down, you can do this:
Otherwise just use
round. Or use the string formatter if you don’t mind your float turning into a string.