By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,601 Members | 989 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,601 IT Pros & Developers. It's quick & easy.

ceil ceils what should be an integer

P: 1
I have a simple calculation, which results in 110, but when i use ceil on the result i get 111, is there something hidden in the result variable?

code:

$result = 66/(100-40)*100;
echo "Result: $result | with Ceil: ". ceil($result);

update: i found a solution here: http://stackoverflow.com/questions/7...ith-no-decimal

$result = round($result,2); // does the trick
Nov 28 '11 #1
Share this Question
Share on Google+
1 Reply


omerbutt
100+
P: 638
hi ,
you need to look at the floval() and intval() function also if you are dealing with decimal calculations to preserve the decimal places when adding or subtracting , specially when dealing with shopping carts and other price calculation based work
regards,
Omer Aslam
Nov 28 '11 #2

Post your reply

Sign in to post your reply or Sign up for a free account.