ceil ceils what should be an integer

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • John Meyers
    New Member
    • Nov 2011
    • 1

    ceil ceils what should be an integer

    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
  • omerbutt
    Contributor
    • Nov 2006
    • 638

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

    Comment

    Working...