round down to nearest number
Chris Kaynor
ckaynor at zindagigames.com
Thu Feb 9 20:41:51 EST 2012
More information about the Python-list mailing list
Thu Feb 9 20:41:51 EST 2012
- Previous message (by thread): round down to nearest number
- Next message (by thread): round down to nearest number
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Thu, Feb 9, 2012 at 5:40 PM, Chris Kaynor <ckaynor at zindagigames.com>wrote: > On Thu, Feb 9, 2012 at 5:23 PM, noydb <jenn.duerr at gmail.com> wrote: > >> hmmm, okay. >> >> So how would you round UP always? Say the number is 3219, so you want >> 3300 returned. >> > > You may want to look into the mathematical floor and ceiling functions[1]. > Python exposes them in the math module as floor and ceil[2]. > > [1] http://en.wikipedia.org/wiki/Floor_and_ceiling_functions > [2] http://docs.python.org/library/math.html#math.floor and > http://docs.python.org/library/math.html#math.ceil > > I should have added, you can use multiplication and division to apply those functions to other digits rather than the base one. For example, multiply by 10, floor, divide by ten, will floor to one decimal point. > -- >> http://mail.python.org/mailman/listinfo/python-list >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-list/attachments/20120209/938a0ed4/attachment-0001.html>
- Previous message (by thread): round down to nearest number
- Next message (by thread): round down to nearest number
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list