By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,919 Members | 1,866 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,919 IT Pros & Developers. It's quick & easy.

RE: How to round a floating point to nearest 10?

P: n/a
>>round(76.1, -2)
>>round(76.1, -1)
builtin function round, will work for you......
Help on built-in function round in module __builtin__:
round(number[, ndigits]) -floating point number

Round a number to a given precision in decimal digits (default 0 digits).
This always returns a floating point number. Precision may be negative.

good luck..

-----Original Message-----
From: py************************************************ **
[mailto:py***************************************** *********]
On Behalf Of John Machin
Sent: Saturday, August 09, 2008 5:54 PM
To: py*********
Subject: Re: How to round a floating point to nearest 10?
On Aug 10, 1:19 am, Mensanator <mensana...@aol.comwrote:
On Aug 9, 6:31 am, Will Rocisky <geekm...@gmail.comwrote:
I want my 76.1 to be rounded to decimal 80 and 74.9 to decimal 70.
How can I achieve that?
>print '%.0e' % 74.9
>print '%.0e' % 76.1

>>print '%.0e' % 176.1

Giving the Subject ("How to round a floating point to nearest 10?"),
there's a strong presumption that the OP would want the answer to be
180, not 200.
The information contained in this message and any attachment may be
proprietary, confidential, and privileged or subject to the work
product doctrine and thus protected from disclosure. If the reader
of this message is not the intended recipient, or an employee or
agent responsible for delivering this message to the intended
recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly prohibited.
If you have received this communication in error, please notify me
immediately by replying to this message and deleting it and all
copies and backups thereof. Thank you.
Aug 9 '08 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.