yeahz Posted February 13, 2009 Report Share Posted February 13, 2009 Kāda funkcija ir jāizmanto lai samazinātu, piemēram šādu skaitli 2.4636 uz 2.46? Link to comment Share on other sites More sharing options...
Roze Posted February 13, 2009 Report Share Posted February 13, 2009 round(), ceil() vai floor() atkarībā no vajadzīgā (apaļot, apaļot uz augšu, apaļot uz leju).. Link to comment Share on other sites More sharing options...
yeahz Posted February 13, 2009 Author Report Share Posted February 13, 2009 nē, apaļot nevajag, vajag tikai nogriezt tos pēdējos ciparus, pat ja arī aiz tā skaitļa ir vēl 10 cipari tad lai paliek tikai divi aiz komata. Link to comment Share on other sites More sharing options...
Roze Posted February 13, 2009 Report Share Posted February 13, 2009 Tad number_format Link to comment Share on other sites More sharing options...
yeahz Posted February 13, 2009 Author Report Share Posted February 13, 2009 Paldies, laikam izdevās. P.S. lūdzu pārbaudiet, vai esmu pareizi uztaisījis funkciju. //nosaka svaru gramos, kilogramos, tonnaas function svars($value) { //viss tiek sveerts GRAMOS! $kilograms = 1000; $tonna = 1000000; if ($value < $kilograms) { echo $value . " g"; } elseif ($value > $kilograms && $value < $tonna) { echo number_format($value/$kilograms, 2, '.', '') . " kg"; } elseif ($value > $tonna) { echo number_format($value/$tonna, 2, '.', '') . " t"; } } Link to comment Share on other sites More sharing options...
Recommended Posts