[PHP] Rounding down?

2009-08-22 Thread Ron Piggott
Is there a way to round down to the nearest 50? Example: Any number between 400 and 449 I would 400 to be displayed; 450 to 499 would be 450; 500 to 549 would be 500, etc? The original number of subscribers is from a mySQL query and changes each day. I am trying to present a factual

Re: [PHP] Rounding down?

2009-08-22 Thread Richard Heyes
Hi, Is there a way to round down to the nearest 50? Example: Any number between 400 and 449 I would 400 to be displayed; 450 to 499 would be 450; 500 to 549 would be 500, etc? Off the top of my head: divide the number by 50, run floor() on the result, then times it by 50. 1. 449 / 50 =

Re: [PHP] Rounding down?

2009-08-22 Thread Ashley Sheridan
On Sat, 2009-08-22 at 13:00 +0100, Richard Heyes wrote: Hi, Is there a way to round down to the nearest 50? Example: Any number between 400 and 449 I would 400 to be displayed; 450 to 499 would be 450; 500 to 549 would be 500, etc? Off the top of my head: divide the number by 50,

Re: [PHP] Rounding down?

2009-08-22 Thread Ron Piggott
Thanks; Amazing. Ron - Original Message - From: Ashley Sheridan a...@ashleysheridan.co.uk To: Richard Heyes rich...@php.net Cc: Ron Piggott ron@actsministries.org; php-general@lists.php.net Sent: Saturday, August 22, 2009 9:02 AM Subject: Re: [PHP] Rounding down? On Sat, 2009

Re: [PHP] Rounding down?

2009-08-22 Thread דניאל דנון
; Amazing. Ron - Original Message - From: Ashley Sheridan a...@ashleysheridan.co.uk To: Richard Heyes rich...@php.net Cc: Ron Piggott ron@actsministries.org; php-general@lists.php.net Sent: Saturday, August 22, 2009 9:02 AM Subject: Re: [PHP] Rounding down? On Sat, 2009-08-22

Re: [PHP] Rounding down?

2009-08-22 Thread Richard Heyes
Hi, It should be round() and not floor(). 449 / 50 = 8.98 floor(8.98) = 8 8 * 50 = 400 round(8.98) = 9 9 * 50 = 450 Not based on the examples given: Example: Any number between 400 and 449 I would 400 to be displayed -- Richard Heyes HTML5 graphing: RGraph - www.rgraph.net (updated

Re: [PHP] Rounding down?

2009-08-22 Thread Richard Heyes
Hi, ... A little modification: ?php /** * Rounds down to the nearest 50 */ function myRound($val) { $units = intval(substr($val, -2)); return intval(substr($val, 0, -2) . ($units = 50 ? '50' : '00')); } echo myRound(449) . 'br /'; // 400 echo

Re: [PHP] Rounding down?

2009-08-22 Thread Clancy
On Sat, 22 Aug 2009 14:02:58 +0100, a...@ashleysheridan.co.uk (Ashley Sheridan) wrote: On Sat, 2009-08-22 at 13:00 +0100, Richard Heyes wrote: Hi, Is there a way to round down to the nearest 50? Example: Any number between 400 and 449 I would 400 to be displayed; 450 to 499 would be

[PHP] rounding down

2004-11-26 Thread Brad Ciszewski
hi everyone, i am looking for a snipplet to round down a number. i was wondering if you could put a negative number in the round() statement to do this, i want it to round down even if its at something.9, as long as its not a whole number, if needs to be rounded down. can anyone help me?

Re: [PHP] rounding down

2004-11-26 Thread John Nichel
Brad Ciszewski wrote: hi everyone, i am looking for a snipplet to round down a number. i was wondering if you could put a negative number in the round() statement to do this, i want it to round down even if its at something.9, as long as its not a whole number, if needs to be rounded down. can

Re: [PHP] rounding down

2004-11-26 Thread David Bevan
On November 26, 2004 08:58, Brad Ciszewski wrote: hi everyone, i am looking for a snipplet to round down a number. i was wondering if you could put a negative number in the round() statement to do this, i want it to round down even if its at something.9, as long as its not a whole number, if

Re: [PHP] rounding down

2004-11-26 Thread Marek Kilimajer
Brad Ciszewski wrote: hi everyone, i am looking for a snipplet to round down a number. i was wondering if you could put a negative number in the round() statement to do this, i want it to round down even if its at something.9, as long as its not a whole number, if needs to be rounded down. can