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:
@@ -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);
|
||||
|
Reference in New Issue
Block a user