<?php
require_once "magnitudePrefix.class.php";
$mp = new MagnitudePrefix();
//Some numbers
echo"<br>Some Numbers<br>";
$number = 0.2;
echo $number . " => " . $mp->getPrefixed($number, 'seconds') . "<BR/>";
$number = 0.002;
echo $number . " => " . $mp->getPrefixed($number, 'grams') . "<BR/>";
$number = 200;
echo $number . " => " . $mp->getPrefixed($number, 'Volts') . "<BR/>";
$number = 200000;
echo $number . " => " . $mp->getPrefixed($number, 'Ohms') . "<BR/>";
$number = 0.00002;
echo $number . " => " . $mp->getPrefixed($number, 'Farads') . "<BR/>";
//An expression, result from random calculation
echo"<br>An expression, result from random calculation<br>";
$number = round(rand() * exp(rand(-23,23)),2);
echo $number . " => " . $mp->getPrefixed($number, 'meters') . "<BR/>";
//Expand scale
echo"<br>Expand scale<br>";
$mp->setScaleToExpandedStandard();
$number = 0.25;
echo $number . " => " . $mp->getPrefixed($number, 'meters') . "<BR/>";
//Use Years
echo"<br>Use Years<br>";
$mp->setScaleToYears();
$number = 250;
echo $number . " => " . $mp->getPrefixed($number, '') . "<BR/>";
//Custom scale
echo"<br>Custom scale<br>";
$mp->setScaleToCustom(array(
array('factor'=>1E-3, 'prefix'=>'mili'),
array('factor'=>1E-2, 'prefix'=>'centi'),
array('factor'=>1, 'prefix'=>''),
array('factor'=>1E3, 'prefix'=>'Kilo')
)
);
$number = 250;
echo $number . " => " . $mp->getPrefixed($number, 'meters') . "<BR/>";
$number = 0.43;
echo $number . " => " . $mp->getPrefixed($number, 'meters') . "<BR/>";
$number = 0.005;
echo $number . " => " . $mp->getPrefixed($number, 'meters') . "<BR/>";
?>
|