[SOLVED] Rounding Numbers

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lokksta
Forum Newbie
Posts: 2
Joined: Tue Oct 12, 2004 5:27 am

Rounding Numbers

Post by lokksta »

Well I guess my question is kind of rounding.

What I want to do is, say I had any number between 0 and 1, I would want that number to be rounded up to 1, even if it was 0.1 which would technically be closer to 0.

I have tried the basic round() function but wouldn’t get it to do what I want, as it was rounding to the closest number (rounding 0.1 to 0 instead of 1 as I want).

I think what I am looking for is some kind of 'if it is more than 0 round it to 1 and if it is more than 1 round it to 2' and so on.

I would really appreciate it if anyone could help, the answer is probably much easier than I think.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

So you consult the manual:

[php_man]round[/php_man]

Have a look at related functions, mentioned with " See also:"

you will see for example [php_man]ceil[/php_man]
lokksta
Forum Newbie
Posts: 2
Joined: Tue Oct 12, 2004 5:27 am

Post by lokksta »

Thanks for your reply, I had looked breifly at the manual and didn't see the ceil() function, thanks for pointing it out, it looks like it can do what im after.
Post Reply