round down to nearest number

MRAB python at mrabarnett.plus.com
Fri Feb 10 04:39:08 CET 2012


On 10/02/2012 03:29, Terry Reedy wrote:
> On 2/9/2012 8:23 PM, noydb wrote:
>>  So how would you round UP always?  Say the number is 3219, so you want
>   >>>  (3333//100+1)*100
> 3400
>
Doing it that way doesn't always work. For example:

 >>> (3400 // 100 + 1) * 100
3500

However:

 >>> (3400 + 99) // 100 * 100
3400



More information about the Python-list mailing list