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
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 =
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,
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
; 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
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
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
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
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?
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
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
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
12 matches
Mail list logo