ILIAS
Release_5_0_x_branch Revision 61816
|
Class for converting between different unit-lengths as specified by CSS. More...
Public Member Functions | |
__construct ($output_precision=4, $internal_precision=10, $force_no_bcmath=false) | |
convert ($length, $to_unit) | |
Converts a length object of one unit into another unit. | |
getSigFigs ($n) | |
Returns the number of significant figures in a string number. |
Data Fields | |
const | ENGLISH = 1 |
const | METRIC = 2 |
const | DIGITAL = 3 |
Protected Attributes | |
$outputPrecision | |
Minimum bcmath precision for output. | |
$internalPrecision | |
Bcmath precision for internal calculations. |
Static Protected Attributes | |
static | $units |
Units information array. |
Private Member Functions | |
add ($s1, $s2, $scale) | |
Adds two numbers, using arbitrary precision when available. | |
mul ($s1, $s2, $scale) | |
Multiples two numbers, using arbitrary precision when available. | |
div ($s1, $s2, $scale) | |
Divides two numbers, using arbitrary precision when available. | |
round ($n, $sigfigs) | |
Rounds a number according to the number of sigfigs it should have, using arbitrary precision when available. | |
scale ($r, $scale) | |
Scales a float to $scale digits right of decimal point, like BCMath. |
Private Attributes | |
$bcmath | |
Whether or not BCMath is available. |
Class for converting between different unit-lengths as specified by CSS.
Definition at line 7 of file UnitConverter.php.
HTMLPurifier_UnitConverter::__construct | ( | $output_precision = 4 , |
|
$internal_precision = 10 , |
|||
$force_no_bcmath = false |
|||
) |
Definition at line 56 of file UnitConverter.php.
|
private |
Adds two numbers, using arbitrary precision when available.
string | $s1 | |
string | $s2 | |
int | $scale |
Definition at line 214 of file UnitConverter.php.
References scale().
HTMLPurifier_UnitConverter::convert | ( | $length, | |
$to_unit | |||
) |
Converts a length object of one unit into another unit.
HTMLPurifier_Length | $length | Instance of HTMLPurifier_Length to convert. You must validate() it before passing it here! |
string | $to_unit | Unit to convert to. |
Definition at line 82 of file UnitConverter.php.
References $log, $n, $outputPrecision, div(), getSigFigs(), mul(), and round().
|
private |
Divides two numbers, using arbitrary precision when available.
string | $s1 | |
string | $s2 | |
int | $scale |
Definition at line 246 of file UnitConverter.php.
References scale().
Referenced by convert().
HTMLPurifier_UnitConverter::getSigFigs | ( | $n | ) |
Returns the number of significant figures in a string number.
string | $n | Decimal number |
Definition at line 192 of file UnitConverter.php.
References $n.
Referenced by convert().
|
private |
Multiples two numbers, using arbitrary precision when available.
string | $s1 | |
string | $s2 | |
int | $scale |
Definition at line 230 of file UnitConverter.php.
References scale().
Referenced by convert().
|
private |
Rounds a number according to the number of sigfigs it should have, using arbitrary precision when available.
float | $n | |
int | $sigfigs |
Definition at line 262 of file UnitConverter.php.
Referenced by convert(), and scale().
|
private |
Scales a float to $scale digits right of decimal point, like BCMath.
float | $r | |
int | $scale |
Definition at line 289 of file UnitConverter.php.
References round().
Referenced by add(), div(), mul(), and round().
|
private |
|
protected |
|
protected |
Minimum bcmath precision for output.
int
Definition at line 42 of file UnitConverter.php.
Referenced by convert().
|
staticprotected |
Units information array.
Units are grouped into measuring systems (English, Metric), and are assigned an integer representing the conversion factor between that unit and the smallest unit in the system. Numeric indexes are actually magical constants that encode conversion data from one system to the next, with a O(n^2) constraint on memory (this is generally not a problem, since the number of measuring systems is small.)
Definition at line 23 of file UnitConverter.php.
const HTMLPurifier_UnitConverter::DIGITAL = 3 |
Definition at line 12 of file UnitConverter.php.
const HTMLPurifier_UnitConverter::ENGLISH = 1 |
Definition at line 10 of file UnitConverter.php.
const HTMLPurifier_UnitConverter::METRIC = 2 |
Definition at line 11 of file UnitConverter.php.