1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-08-05 05:37:49 +02:00

Improve floating point scaling in UnitConverter.

When precision dictates that a number be zero padded, we cannot give sprintf()
a negative precision specifier.  This commit implements manual negative precision
printing of floats, taking into account common rounding errors with floating
point numbers.

Signed-off-by: Edward Z. Yang <edwardzyang@thewritingpot.com>
This commit is contained in:
Edward Z. Yang
2008-10-24 12:50:59 -04:00
parent 25fa53c15b
commit 3a2fd0b5db
4 changed files with 38 additions and 3 deletions

View File

@@ -94,6 +94,10 @@ class HTMLPurifier_UnitConverterTest extends HTMLPurifier_Harness
$this->assertConversion('11.112pt', '0.15433in');
}
function __onlytestRoundingBigNumber() {
$this->assertConversion('444400000000000000000000in', '42660000000000000000000000px');
}
protected function assertSigFig($n, $sigfigs) {
$converter = new HTMLPurifier_UnitConverter();
$result = $converter->getSigFigs($n);