autly Posted November 7, 2008 Report Share Posted November 7, 2008 $tot_votes = dbcount("(rating_item_id)", "ratings", "rating_item_id='".$rating_item_id."' AND rating_type='".$rating_type."'"); $query = "SELECT rating_item_id, SUM(rating_vote) FROM rusfusion_ratings WHERE rating_item_id='".$rating_item_id."' GROUP BY rating_item_id "; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($result); $summa = $row['SUM(rating_vote)']; if($tot_votes == 0) { } else { $avg = $summa / $tot_votes; Kaa var noapalot liiidz 0.1? Gadas ka vins izdod 4.66666667, bet vajadzeetu lai 4.6. Noteikti ir kkada komandu, par kuras eksistenci vnk nezinu ;) Link to comment Share on other sites More sharing options...
andrisp Posted November 7, 2008 Report Share Posted November 7, 2008 Zini kā "noapaļot" ir angliski ? Link to comment Share on other sites More sharing options...
Aleksejs Posted November 7, 2008 Report Share Posted November 7, 2008 Ja izdod 4.666666667, tad noapaļojot līdz desmitdaļām sanāk 4.7 nevis 4.6 Link to comment Share on other sites More sharing options...
codez Posted November 7, 2008 Report Share Posted November 7, 2008 Ja izvadē tikai vajag, tad ar: http://lv.php.net/number-format Link to comment Share on other sites More sharing options...
rausis Posted November 7, 2008 Report Share Posted November 7, 2008 http://lv.php.net/round ? Link to comment Share on other sites More sharing options...
bubu Posted November 7, 2008 Report Share Posted November 7, 2008 Ja izdod 4.666666667, tad noapaļojot līdz desmitdaļām sanāk 4.7 nevis 4.6 Noapaļot var arī uz leju, Aleksej ;) Link to comment Share on other sites More sharing options...
Aleksejs Posted November 7, 2008 Report Share Posted November 7, 2008 Jā, bet tad to vairs nesauc par apaļošanu, ne? ;) Ai, nu tā jau tiešām ir matu skaldīšana: rond() floor() ceil() Izvēlamies, kas der. Link to comment Share on other sites More sharing options...
bubu Posted November 7, 2008 Report Share Posted November 7, 2008 Kā tad to sauc? Man mācīja, ka to tāpat vien sauc - par apaļošanu. Apaļot var uz leju, uz augšu, līdz tuvākajam veselajam skaitlim, uz 0 pusi, uz +/- bezgalības pusi. Variantu daudz. Tāda defaultā varianta nemaz nav. Link to comment Share on other sites More sharing options...
v3rb0 Posted November 7, 2008 Report Share Posted November 7, 2008 par flõrošanu un ceilošanu to sauc :] Link to comment Share on other sites More sharing options...
autly Posted November 7, 2008 Author Report Share Posted November 7, 2008 lil kljudijos ;) btw izmantoju format ;) paldies par atsauksmi ;) Link to comment Share on other sites More sharing options...
werd Posted November 7, 2008 Report Share Posted November 7, 2008 Tā jau arī ir, noapaļot uz leju matemātiski pareizi sauc par noapaļošanu ar iztrūkumu, bet noapaļot uz augšu - noapaļošanu ar uzviju! :) Link to comment Share on other sites More sharing options...
Recommended Posts