[PHP] PHP Rounding Question

2011-05-20 Thread Rick Dwyer
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

Re: [PHP] PHP Rounding Question

2011-05-20 Thread David Harkness
On Fri, May 20, 2011 at 10:40 AM, Rick Dwyer rpdw...@earthlink.net wrote: How do I coerce the result to always round up to the nearest increment 1/4? $x = ceil($x * 4) / 4; David

[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 -- was [PHP] round to nearest 500?

2007-02-14 Thread tedd
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 up -

[PHP] rounding test fails when I try to make test

2005-03-24 Thread Larry
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)

[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

[PHP] rounding average to one decimal point

2004-05-10 Thread Adam Williams
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

Re: [PHP] rounding average to one decimal point

2004-05-10 Thread Richard Davey
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 don't

Re: [PHP] rounding average to one decimal point

2004-05-10 Thread Daniel Clark
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

Re: [PHP] rounding average to one decimal point

2004-05-10 Thread Adam Williams
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 number

[PHP] Rounding issue

2003-07-29 Thread Kevin Ison
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

Re: [PHP] Rounding issue

2003-07-29 Thread Larry E . Ullman
$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

Re: [PHP] Rounding issue

2003-07-29 Thread Curt Zirzow
* 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? I have

Re: [PHP] Rounding issue

2003-07-29 Thread Kevin Ison
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 want 2

Re: [PHP] Rounding issue

2003-07-29 Thread Kevin Ison
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 following

[PHP] PHP Rounding Time

2003-04-04 Thread Jay Fitzgerald
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 -

[PHP] Re: PHP Rounding Time

2003-04-04 Thread Philip Hallstrom
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 ) { $ts = $ts

Re: [PHP] PHP Rounding Time

2003-04-04 Thread Burhan Khalid
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

[PHP] Rounding

2003-02-20 Thread Van Andel, Robbert
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

Re: [PHP] Rounding

2003-02-20 Thread Ernest E Vogelsinger
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]

Re: [PHP] Rounding

2003-02-20 Thread Jason Wong
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 leave

Re: [PHP] Rounding

2003-02-20 Thread Steve Keller
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 Health TV

[PHP] rounding...sort of

2002-12-28 Thread Peter Lavender
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:

Re: [PHP] rounding...sort of

2002-12-28 Thread Jason Wong
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 - Gremlins

Re: [PHP] rounding...sort of

2002-12-28 Thread Justin French
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 whole number 4, even if it's 4.9, so this rules out using round (Unless I missed a

Re: [PHP] rounding...sort of

2002-12-28 Thread Rasmus Lerdorf
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 whole number 4,

Re: [PHP] rounding a number

2002-06-24 Thread George Whiffen
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 there a function

Re: [PHP] rounding a number

2002-06-24 Thread Jim lucas
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 decimal place... if the number is 4.623, I want it to display 4.6

Re: [PHP] rounding a number

2002-06-24 Thread Jason Wong
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.3 on

[PHP] rounding a number

2002-06-23 Thread Phil Schwarzmann
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

RE: [PHP] rounding a number

2002-06-23 Thread Martin Towell
: [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 all the math

RE: [PHP] rounding a number

2002-06-23 Thread Jason Soza
- 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 display 2.7

Re: [PHP] rounding a number

2002-06-23 Thread Jason Wong
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? round(),

[PHP] Rounding....

2002-02-10 Thread Matthew Clark
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.5mn+1, I wonder why the PHP round() function couldn't include a little 'fuzz' to handle the rounding problems we encounter due to floating point representation in the hardware? It

Re: [PHP] Rounding....

2002-02-10 Thread Bogdan Stancescu
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 to

[PHP] Rounding a number up

2001-09-10 Thread Brandon Orther
Is there a way to round a number to the next whole number? Example: Before: 1.86758 After: 2 Thank you,

Re: [PHP] Rounding a number up

2001-09-10 Thread Lance Rochelle
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 to round a number to the next whole number

RE: [PHP] rounding up

2001-04-27 Thread Joseph Bannon
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]

[PHP] rounding up

2001-04-25 Thread Joseph Bannon
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]

RE: [PHP] rounding up

2001-04-25 Thread Matt Williams
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,

RE: [PHP] rounding up

2001-04-25 Thread John Huggins
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 to be

[PHP] Rounding to strange results

2001-03-06 Thread Martin E. Koss
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

RE: [PHP] Rounding to strange results

2001-03-06 Thread Johnson, Kirk
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

RE: [PHP] Rounding to strange results

2001-03-06 Thread Rick St Jean
: 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 .10 and on the other site there is no tax and also no rounding

[PHP] Rounding a number up if the number is anything more than a whole number

2001-01-17 Thread Brandon Orther
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

Re: [PHP] Rounding a number up if the number is anything more thana whole number

2001-01-17 Thread Ignacio Vazquez-Abrams
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 equal 4