nec9716 Posted April 24, 2008 Share Posted April 24, 2008 When I run that: $totalr = round(10.333333, -2); I should have something but the print value of $totalr is always 0.....I was thinking to see something like 10.33 but no luck Quote Link to comment Share on other sites More sharing options...
p2grace Posted April 24, 2008 Share Posted April 24, 2008 Try this: $totalr = round(10.333333, 2); Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted April 24, 2008 Share Posted April 24, 2008 Why would you want -2 decimals? That's not possible. Quote Link to comment Share on other sites More sharing options...
p2grace Posted April 24, 2008 Share Posted April 24, 2008 Actually it is, if he had round(10456,-2) it would round to 10500. He just doesn't have enough digits. Quote Link to comment Share on other sites More sharing options...
nec9716 Posted April 24, 2008 Author Share Posted April 24, 2008 I really apologize...type mismatch..... i have write that: $totalr = round(10.333333, -2); but ....there no "-" $totalr = round(10.333333, 2); sorry Quote Link to comment Share on other sites More sharing options...
p2grace Posted April 24, 2008 Share Posted April 24, 2008 That code works, I just tested it. It results 10.33 Quote Link to comment Share on other sites More sharing options...
nec9716 Posted April 24, 2008 Author Share Posted April 24, 2008 yes ...just try it as well..... now if I want to round a value of a variable like: $total = $row['total']; $totalr = round($total,2); is that the way to write that? thank you ..... Quote Link to comment Share on other sites More sharing options...
p2grace Posted April 24, 2008 Share Posted April 24, 2008 Looks like you just did. That should work. If it's not parsing it as a float try this: $total = $row['total']; (float) $total; $totalr = round($total,2); Quote Link to comment Share on other sites More sharing options...
nec9716 Posted April 24, 2008 Author Share Posted April 24, 2008 thank you it work fine now.... thank again Quote Link to comment Share on other sites More sharing options...
p2grace Posted April 24, 2008 Share Posted April 24, 2008 Glad I could help, when you get a chance could you mark the topic as solved Thank you. EDIT: Woops I see you already did Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.