Re: [PHP] Math rounding problem
Charlie, For an arbitrary large number I need to round() it up to the hundreds place if it is not divisible by 100 and leave it untouched if it is. So 1100 would round to 1100 and 1101 would round to 1200. Is there a clean way to do this? Currently I'm: $scale = round($scale+49, -2); // round up to hundreds. But this is messy. You thought that was messy? Try: if ( ( intval( $scale / 100 ) * 100 ) $scale ) { $scale = 1 + ( intval( $scale / 100 ) * 100 ); } Regards, =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Math rounding problem
This equation from Bogdan is simple and working: $scale=ceil($scale/100)*100; Thanks to all those who helped, Charlie -Original Message- From: Bogdan Stancescu [mailto:[EMAIL PROTECTED]] $scale=ceil($scale/100)*100, maybe? Bogdan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Math rounding problem
ceil() maybe - Original Message - From: Charlie Killian [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, February 08, 2002 4:14 PM Subject: [PHP] Math rounding problem For an arbitrary large number I need to round() it up to the hundreds place if it is not divisible by 100 and leave it untouched if it is. So 1100 would round to 1100 and 1101 would round to 1200. Is there a clean way to do this? Currently I'm: $scale = round($scale+49, -2); // round up to hundreds. But this is messy. Charlie -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php