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 Link to comment https://forums.phpfreaks.com/topic/102732-solved-trouble-with-round-fonction/ Share on other sites More sharing options...
p2grace Posted April 24, 2008 Share Posted April 24, 2008 Try this: $totalr = round(10.333333, 2); Link to comment https://forums.phpfreaks.com/topic/102732-solved-trouble-with-round-fonction/#findComment-526100 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. Link to comment https://forums.phpfreaks.com/topic/102732-solved-trouble-with-round-fonction/#findComment-526101 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. Link to comment https://forums.phpfreaks.com/topic/102732-solved-trouble-with-round-fonction/#findComment-526107 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 Link to comment https://forums.phpfreaks.com/topic/102732-solved-trouble-with-round-fonction/#findComment-526113 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 Link to comment https://forums.phpfreaks.com/topic/102732-solved-trouble-with-round-fonction/#findComment-526118 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 ..... Link to comment https://forums.phpfreaks.com/topic/102732-solved-trouble-with-round-fonction/#findComment-526120 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); Link to comment https://forums.phpfreaks.com/topic/102732-solved-trouble-with-round-fonction/#findComment-526132 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 Link to comment https://forums.phpfreaks.com/topic/102732-solved-trouble-with-round-fonction/#findComment-526236 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 Link to comment https://forums.phpfreaks.com/topic/102732-solved-trouble-with-round-fonction/#findComment-526242 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.