Need to Round Off some numbers
Posted: Wed Dec 29, 2004 11:08 pm
I have these numbers with decimals that I need to round off and not being a good math guy, hoped you guys had some suggestions.
The following are the variables and then the number they yeild.
the current value of $barPressure is 29.98
and of $windSpeed is 16 (in MPH)
The above converts them to metric equivalents.
on the barometer I need to round off to 2 decimal spots and on the windspeed would prefer to round off to 1 decimal spot.
here is the output:
Barometer in mb = 1015.239722 => rounded to 1015.24 ideally
Barometer in mm = 761.492 => rounded to 761.5
Wind KMH = 25.749504 => rounded to 25.7
Wind Knots = 13.903616 => rounded to 13.9
Help is appreciated.
Thanks.
The following are the variables and then the number they yeild.
Code: Select all
// barometer conversions
$millibars = (33.8639 * $barPressure);
$millimeters = (25.4 * $barPressure);
// wind conversions
$windkmh = (1.609344 * $windSpeed);
$windKnots = (.868976 * $windSpeed);and of $windSpeed is 16 (in MPH)
The above converts them to metric equivalents.
on the barometer I need to round off to 2 decimal spots and on the windspeed would prefer to round off to 1 decimal spot.
here is the output:
Barometer in mb = 1015.239722 => rounded to 1015.24 ideally
Barometer in mm = 761.492 => rounded to 761.5
Wind KMH = 25.749504 => rounded to 25.7
Wind Knots = 13.903616 => rounded to 13.9
Help is appreciated.
Thanks.