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 that does this?  round(), ceil(), floor() don't do
  this and I've checked through all the math functions in my handy-dandy
  PHP Functions reference book.

 round() seems to work. What's the problem you're having?


It's worth noting that round doesn't always work e.g.

try round(0.35,1)




 --
 Jason Wong - Gremlins Associates - www.gremlins.com.hk
 Open Source Software Systems Integrators
 * Web Design  Hosting * Internet  Intranet Applications Development *

 /*
 That's no moon...
 -- Obi-wan Kenobi
 */


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] rounding a number

2002-06-24 Thread Jim lucas

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?

Jim Lucas
- Original Message -
From: George Whiffen [EMAIL 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 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(), ceil(), floor() don't do
   this and I've checked through all the math functions in my handy-dandy
   PHP Functions reference book.
 
  round() seems to work. What's the problem you're having?
 

 It's worth noting that round doesn't always work e.g.

 try round(0.35,1)



 
  --
  Jason Wong - Gremlins Associates - www.gremlins.com.hk
  Open Source Software Systems Integrators
  * Web Design  Hosting * Internet  Intranet Applications Development *
 
  /*
  That's no moon...
  -- Obi-wan Kenobi
  */


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




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 4.0.6.

-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *

/*
Elegance and truth are inversely related.
-- Becker's Razor
*/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




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

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
PHP Functions reference book.

Thanks for your help!!!

Or..if it's too hard to do that, I could just use a function that
chops off the end of some decimals, like...

if the number is 2.343234, I want just 2.3
or if the number is 2.545434534534534534, I want just 2.5

Thanks!!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




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

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
PHP Functions reference book.

Thanks for your help!!!

Or..if it's too hard to do that, I could just use a function that
chops off the end of some decimals, like...

if the number is 2.343234, I want just 2.3
or if the number is 2.545434534534534534, I want just 2.5

Thanks!!


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




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(), ceil(), floor() don't do
 this and I've checked through all the math functions in my handy-dandy
 PHP Functions reference book.

round() seems to work. What's the problem you're having?

-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *

/*
That's no moon...
-- Obi-wan Kenobi
*/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




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?
  
 Example: 
  
 Before: 1.86758
  
 After:  2
  
 Thank you,
  
  
 


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

 11.023 would equal 12


   I hope you understand what I am trying to say.


 Thank you,

 
 Brandon Orther
 WebIntellects Design/Development Manager
 [EMAIL PROTECTED]
 800-994-6364
 www.webintellects.com
 


ceil()

-- 
Ignacio Vazquez-Abrams  [EMAIL PROTECTED]


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