round down to nearest number

MRAB python at mrabarnett.plus.com
Thu Feb 9 22:39:08 EST 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