Re: rounding a number
| From: | George Whiffen | Date: | Mon, 24 Jun 2002 09:36:28 +0000 |
| Subject: | Re: rounding a number | ||
| References: | 1 2 | Groups: | php.general php.general |
| Request: | Send a blank email to php-general+get-103560@lists.php.net to get a copy of this message | ||
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
> */