alexguz79 Posted June 28, 2010 Share Posted June 28, 2010 Hey everybody... i have this peace of code that gime me an average between total_hits and atBats (i'm working a baseball league website) but the thing echo all the numbers after the decimal dot... i just want tree... ex: is giving me 0.666666666667 and i could use better .666 anyone knows how to get me there? here's the code: <? $sql5="select total_hits from bateadores_locales WHERE profile_id ='$id' && year = '2010'"; $cons5=mysql_query($sql5); while($resultado5=mysql_fetch_array($cons5)) $suma5+=$resultado5['total_hits']; ?><? $sql6="select ab from bateadores_locales WHERE profile_id ='$id' && year = '2010'"; $cons6=mysql_query($sql6); while($resultado6=mysql_fetch_array($cons6)) $suma6+=$resultado6['ab']; echo (($suma5."") / ($suma6."")) ?> thanks Quote Link to comment Share on other sites More sharing options...
Mchl Posted June 28, 2010 Share Posted June 28, 2010 round floor ceil Quote Link to comment Share on other sites More sharing options...
miancu Posted June 28, 2010 Share Posted June 28, 2010 i found this, maybe it helps you: http://www.farad.com.au/source_code/php/setting_floating_point_precision_src.php Quote Link to comment Share on other sites More sharing options...
alexguz79 Posted June 28, 2010 Author Share Posted June 28, 2010 the ROUND worked ... it was so easy.. thanks 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.