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

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

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

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] 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] 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

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

RE: [PHP] rounding a number

2002-06-23 Thread Martin Towell
according to the pdf version of the manual I have, round() is what you need float round(float val[, int precision]) have another look that the man page -Original Message- From: Phil Schwarzmann [mailto:[EMAIL PROTECTED]] Sent: Monday, June 24, 2002 1:35 PM To: [EMAIL PROTECTED]

RE: [PHP] rounding a number

2002-06-23 Thread Jason Soza
I think what you're looking for is number_format() - you can set decimal places with it and used in combo with round(), ceil(), and/or floor(), you should be able to achieved the desired result. http://www.php.net/manual/en/function.number-format.php HTH, Jason Soza -Original Message-

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(),

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

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]

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

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

RE: [PHP] Rounding to strange results

2001-03-06 Thread Rick St Jean
You can write a function that get the %(mod) of 1000 then subtracts it from the number. Rick At 08:43 AM 3/6/01 -0700, Johnson, Kirk wrote: 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:

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