in reply to Rounding to the nearest 50

for positive integers try
$x = 151; print (int(( $x + 50 -1 ) / 50) * 50);
Update: As esskar pointed out I missed a -1.
Boris

Replies are listed 'Best First'.
Re: Re: Rounding to the nearest 50
by esskar (Deacon) on Mar 01, 2004 at 14:16 UTC
    well... but this way, setting $x = 250 will result in 300... but this is not what he wants