RE: [PHP] How to Round to the Nearest Multiple of 50?

From: Date: Thu, 14 Sep 2000 05:16:15 +0000
Subject: RE: [PHP] How to Round to the Nearest Multiple of 50?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-16710@lists.php.net to get a copy of this message
I have always had a great amount of luck multiplying the number to a higher level (such as * 50) and then dividing in order to accomplish these sorts of "rounding" features. Let me know if you need more help and I'll provide specific examples. Dan > -----Original Message----- > From: Richard Creech [mailto:richardc@dreamriver.com] > Sent: Thursday, September 14, 2000 1:10 AM > To: php-general@lists.php.net > Subject: [PHP] How to Round to the Nearest Multiple of 50? > > > Hello All, > I have an integer variable - lets call it $scaleHeight - > somewhere between 0 and 1200. In all likelihood this variable > will not be a multiple of 50. It will be 49 or 51 or 1143 or 856 ... > > How do I round $scaleHeight to the Nearest Multiple of 50? > > The reason I wish to do this is to obtain a variable which I can > then use in a switch statement, which is clearer to code and > faster to run than a whole lot of if statements. > > Anyone know the answer? > > Regards, > > Richard Creech > richardc@dreamriver.com Phone: 250.744.3350 Pacific Time Canada > Download phpYellow Pages 2000 - BETA > Add Dynamic Database Content to your Website > http://www.dreamriver.com/software/ > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > >

« previous php.general (#16710) next »