On Fri, May 20, 2011 at 10:40 AM, Rick Dwyer wrote:
> How do I coerce the result to always round up to the nearest increment 1/4?
>
$x = ceil($x * 4) / 4;
David
I have a division formula that will return an value from 0.00 to 5...
so I can get values like 2.38 or 4.79.
However, never lower than 0 or higher than 5.
How do I coerce the result to always round up to the nearest increment
1/4? So for example:
2.06 gets rounded to 2.25
0.01 gets rounde
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
>> >
Hi,
> ...
A little modification:
= 50 ? '50' : '00'));
}
echo myRound(449) . ''; // 400
echo myRound(450) . ''; // 450
echo myRound(356) . ''; // 350
echo myRound(79) . ''; // 50
?>
PS I haven't checked if there's a PHP function for this.
--
Richard Heyes
HTML5 graphing:
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 (u
Ron
>
> - Original Message - From: "Ashley Sheridan" <
> a...@ashleysheridan.co.uk>
> To: "Richard Heyes"
> Cc: "Ron Piggott" ; >
> Sent: Saturday, August 22, 2009 9:02 AM
> Subject: Re: [PHP] Rounding down?
>
>
> On Sat, 2009-08-22
Thanks; Amazing. Ron
- Original Message -
From: "Ashley Sheridan"
To: "Richard Heyes"
Cc: "Ron Piggott" ;
Sent: Saturday, August 22, 2009 9:02 AM
Subject: Re: [PHP] Rounding down?
On Sat, 2009-08-22 at 13:00 +0100, Richard Heyes wrote:
Hi,
> Is
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 numbe
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 =
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 statement:
At 8:40 PM +0100 2/13/07, Satyam wrote:
- Original Message - From: "Jon Anderson" <[EMAIL PROTECTED]>
The reason is simple:
0: No rounding. It's already there. (8.0 doesn't need to be rounded
to 8 - it already *is* 8.)
1-4: You round down -> 4 of 9 times you round down.
5-9: You round
Hi,
I am trying to build the latest stable release of php (4.3.10)
I've successfully compiled but when I run "make test"
the following are the two bugs that fail.
FAILED TEST SUMMARY
-
Bug #24142 (round() problems) [ext
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 anyo
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, i
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 anyo
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?
On Mon, 10 May 2004, Richard Davey wrote:
> Hello Adam,
>
> Monday, May 10, 2004, 7:03:36 PM, you wrote:
>
> AW> Hi, I have a randon group of numbers I need the average of. When I add
> AW> them up and divide by how many there are and print the result, I get a
> AW> lot of decimal places. The
How about round()
echo round(1.95583, 2); // 1.96
echo round(1241757, -3); // 1242000
http://www.phpbuilder.com/manual/function.round.php
> Hi, I have a randon group of numbers I need the average of. When I add
> them up and divide by how many there are and print the result, I get a
> lot of
Hello Adam,
Monday, May 10, 2004, 7:03:36 PM, you wrote:
AW> Hi, I have a randon group of numbers I need the average of. When I add
AW> them up and divide by how many there are and print the result, I get a
AW> lot of decimal places. The number comes out to look like 29.3529411765,
AW> but I do
Hi, I have a randon group of numbers I need the average of. When I add
them up and divide by how many there are and print the result, I get a
lot of decimal places. The number comes out to look like 29.3529411765,
but I don't need that many decimal places. rounding to one decimal place
will
ahhh ok thanks guys!! That worked ... I knew it was something but I could
not remember which function...
thanks again!
"Curt Zirzow" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> * Thus wrote Kevin Ison ([EMAIL PROTECTED]):
> > I need to know if there is a work around for the foll
ahhh ok thanks guys!! That worked ... I knew it was something but I could
not remember which function...
thanks again!
"Larry E . Ullman" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> > $x = 4.5012412;
> > echo round($x, 2); // results in 4.5 --- however I want 4.50! I
> > w
* Thus wrote Kevin Ison ([EMAIL PROTECTED]):
> I need to know if there is a work around for the following scenerio...
>
> $x = 4.5012412;
> echo round($x, 2); // results in 4.5 --- however I want 4.50! I want 2
> decimal places!
>
>
> Is there a way to keep the zero from being dropped?
$x = 4.5012412;
echo round($x, 2); // results in 4.5 --- however I want 4.50! I
want 2
decimal places!
echo number_format ( round ($x, 2), 2);
Larry
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
I need to know if there is a work around for the following scenerio...
$x = 4.5012412;
echo round($x, 2); // results in 4.5 --- however I want 4.50! I want 2
decimal places!
Is there a way to keep the zero from being dropped? I have not been able to
get the zero to stay there ... I realiz
Jay Fitzgerald wrote:
I apologize in advance for my constant nub questions..
How can I round the current time up or down to the nearest 1/2 hour?
eg:
timeranges:
0900 through 0915 == 0900
0916 through 0930 == 0930
0931 through 0945 == 0930
0946 through 1000 == 1000
I'm sure there's a better way
I haven't quite thought this through, but I think something like this:
$remainder = $ts % 60;
if( $remainder < 15 ) {
$ts = $ts - $remainder;
}else if( $remainder > 15 && $remainder < 30 ) {
$ts = $ts + (30 - $remainder);
}else if( $remainder > 30 && $remainder < 45 ) {
$t
I apologize in advance for my constant nub questions..
How can I round the current time up or down to the nearest 1/2 hour?
eg:
timeranges:
0900 through 0915 == 0900
0916 through 0930 == 0930
0931 through 0945 == 0930
0946 through 1000 == 1000
Jay Fitzgerald, Design Director
Bayou Internet - http
At 2/21/2003 05:29 AM, Jason Wong wrote:
> To round to the nearest 5:
>
> Divide by 5
> Round to the nearest integer
> Multiply by 5
Modulus by 5
Subtract the result from the original number.
Of course, my way depends on whether you're rounding up or down.
--
S. Keller
UI Engineer
The Healt
On Friday 21 February 2003 05:17, Van Andel, Robbert wrote:
> How do I round a number to the nearest 10 or even 5. Say I have a
> number like 12. Is there an easy way to round that up to 15 or 20?
To round to the nearest 5:
Divide by 5
Round to the nearest integer
Multiply by 5
I'll leav
At 22:17 20.02.2003, Van Andel, Robbert spoke out and said:
[snip]
>How do I round a number to the nearest 10 or even 5. Say I have a
>number like 12. Is there an easy way to round that up to 15 or 20?
[snip]
functi
How do I round a number to the nearest 10 or even 5. Say I have a
number like 12. Is there an easy way to round that up to 15 or 20?
Robbert van Andel
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Use explode() please
On Sun, 29 Dec 2002, Justin French wrote:
> php.net/floor
>
> OR
>
> list($w,$d) = split('.','4.9');
> echo $w;
> ?>
>
> Justin French
>
>
>
> on 28/12/02 8:49 PM, Peter Lavender ([EMAIL PROTECTED]) wrote:
>
> > Hi everyone,
> >
> > I have a nubmer: 4.1 but I only want the w
php.net/floor
OR
Justin French
on 28/12/02 8:49 PM, Peter Lavender ([EMAIL PROTECTED]) wrote:
> Hi everyone,
>
> I have a nubmer: 4.1 but I only want the whole number 4, even if it's
> 4.9, so this rules out using round (Unless I missed a parameter).
>
> How could I do this.. I'm drawing
On Saturday 28 December 2002 17:49, Peter Lavender wrote:
> Hi everyone,
>
> I have a nubmer: 4.1 but I only want the whole number 4, even if it's
> 4.9, so this rules out using round (Unless I missed a parameter).
>
> How could I do this.. I'm drawing a blank...
floor()
--
Jason Wong -> Gremlin
Hi everyone,
I have a nubmer: 4.1 but I only want the whole number 4, even if it's
4.9, so this rules out using round (Unless I missed a parameter).
How could I do this.. I'm drawing a blank...
Pete
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/
On Tuesday 25 June 2002 02:16, Jim lucas wrote:
> seems to work fine for me.
> what are your results when you do this? mine are 0.4 and this is what is
> should be. if it were .349 it would round down. isn't this how it should
> work? What were your results?
> > try round(0.35,1)
I get 0
AIL PROTECTED]>
To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Monday, June 24, 2002 2:36 AM
Subject: Re: [PHP] rounding a number
> Jason Wong wrote:
>
> > On Monday 24 June 2002 11:34, Phil Schwarzmann wrote:
> > > I want to round a number to the nearest decim
Jason Wong wrote:
> On Monday 24 June 2002 11:34, Phil Schwarzmann wrote:
> > I want to round a number to the nearest decimal place...
> >
> > if the number is 4.623, I want it to display 4.6
> > if the number is 2.36, I want it to display 2.7
>
> You don't really mean 2.36 --> 2.7 ??
>
> > Is th
On Monday 24 June 2002 11:34, Phil Schwarzmann wrote:
> I want to round a number to the nearest decimal place...
>
> if the number is 4.623, I want it to display 4.6
> if the number is 2.36, I want it to display 2.7
You don't really mean 2.36 --> 2.7 ??
> Is there a function that does this? rou
ssage-
From: Phil Schwarzmann [mailto:[EMAIL PROTECTED]]
Sent: Sunday, June 23, 2002 7:35 PM
To: [EMAIL PROTECTED]
Subject: [PHP] rounding a number
I want to round a number to the nearest decimal place...
if the number is 4.623, I want it to display 4.6
if the number is 2.36, I want it to displa
: [PHP] rounding a number
I want to round a number to the nearest decimal place...
if the number is 4.623, I want it to display 4.6
if the number is 2.36, I want it to display 2.7
Is there a function that does this? round(), ceil(), floor() don't do
this and I've checked through al
I want to round a number to the nearest decimal place...
if the number is 4.623, I want it to display 4.6
if the number is 2.36, I want it to display 2.7
Is there a function that does this? round(), ceil(), floor() don't do
this and I've checked through all the math functions in my handy-dandy
I guess that's because nobody knows beforehand which direction the fuzz should
go - should it go "a little" upwards or "a little" downwards in order to match
all systems?
Just my two cents.
Bogdan
Matthew Clark wrote:
> Seeing as the mathematically correct way to round numbers is to round down
Seeing as the mathematically correct way to round numbers is to round down
to n for n-1<=m<=n.5 and up to n+1 for n.5http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
http://www.php.net/manual/en/function.ceil.php
- Original Message -
From: "Brandon Orther" <[EMAIL PROTECTED]>
To: "PHP User Group" <[EMAIL PROTECTED]>
Sent: Monday, September 10, 2001 2:19 PM
Subject: [PHP] Rounding a number up
> Is there a way
Is there a way to round a number to the next whole number?
Example:
Before: 1.86758
After: 2
Thank you,
What is the best seamless way to upgrade/update PHP?
Joseph
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]
> > Is there a PHP command to round up to the nearest integer?
>
> www.php.net/ceil
> www.php.net/round
>
These are the correct functions, but take great care in reading the user
contributed notes in the round function concerning x.5 rounding randomness.
Sometimes this can get you.
If you want
Hi
>
> Is there a PHP command to round up to the nearest integer?
www.php.net/ceil
www.php.net/round
HTH
M@
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-ma
Is there a PHP command to round up to the nearest integer?
J
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]
Message-
>From: Martin E. Koss [mailto:[EMAIL PROTECTED]]
>Sent: Tuesday, March 06, 2001 7:45 AM
>To: [EMAIL PROTECTED]
>Subject: [PHP] Rounding to strange results
>
>
>Hi,
>I use a product database for 2 sites, one of which adds sales tax and rounds
>to the nearest
Is there a comma in one thousand, e.g., 1,000.00? round() will truncate
everything to the right of a comma.
Kirk
-Original Message-
From: Martin E. Koss [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, March 06, 2001 7:45 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Rounding to strange results
Hi
Hi,
I use a product database for 2 sites, one of which adds sales tax and rounds
to the nearest .10 and on the other site there is no tax and also no
rounding.
I am unable to figure out why a price of 1000.00 is being displayed as 1.00
and any price over 1000 does the same thing. 100.00 works fin
On Mon, 17 Jan 2000, Brandon Orther wrote:
> Hello,
>
> I am doing a math function where I divide one number by another. I want it
> to give me a whole number though, and if it is anything above a number I
> want it to go to the next one up.
>
> Example:
>
> 4.0001 would equal 5
>
> 3.98 would
Hello,
I am doing a math function where I divide one number by another. I want it
to give me a whole number though, and if it is anything above a number I
want it to go to the next one up.
Example:
4.0001 would equal 5
3.98 would equal 4
11.023 would equal 12
I hope you understand what
56 matches
Mail list logo