note 27933 rejected from function.number-format by jmcastagnetto

From: Date: Thu, 26 Dec 2002 06:17:44 +0000
Subject: note 27933 rejected from function.number-format by jmcastagnetto
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-41294@lists.php.net to get a copy of this message
In this function... How can I round decimals to get the final result at Kilometers per hour from Miles per hour WITHOUT so many decimals and keeping the precision? function convertSpeed($mph,$metric) { if (!$mph) return(false); if (strtolower($metric) == "mph") return($mph); if (strtolower($metric) == "kph") return($mph * 1.609344); } Another example is from Fahrenheit to Celsius... function convertTemp($fTemp,$metric) { if (!$fTemp) return(false); if (!doubleval($fTemp)) return($fTemp); if (strtolower($metric) == "f") return($fTemp); if (strtolower($metric) == "c") return(($fTemp - 32) * 5/9); } Some idea to round the final number? Thanks.

« previous php.notes (#41294) next »