Language::formatBitrate( 1000000000000000 ) gives '1,000Tbps' when it should be '1Pbps'.
The end result is 'languages/LanguageTest.php' test suite gives a failure:
- LanguageTest::testFormatBitrate with data set #5 (1000000000000000, '1Pbps', '1 petabit per second')
formatBitrate('1000000000000000'): 1 petabit per second
Failed asserting that two strings are equal.
- Expected
+++ Actual
@@ @@
-'1Pbps'
+'1,000Tbps'
The root cause is using floor() on a float returned by log(). That might be rounded down to the wrong integer :-/
As an example on http://codepad.org/VBkuWR8m
print floor(log10(1000000000000000)) . "\n";
outputs 15, correct
print floor(log(1000000000000000,10)) . "\n";
outputs 14 (WRONG)
print floor(log10(1000)) . "\n";
outputs 3, correct
print floor(log( 1000, 10 )) . "\n";
outputs 2 (WRONG)
On a Mac with PHP:
PHP 5.3.6 with Suhosin-Patch (cli) (built: Sep 8 2011 19:34:00)
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
with Xdebug v2.1.2, Copyright (c) 2002-2011, by Derick Rethans
print floor(log10(1000000000000000)) . "\n";
outputs 14 (WRONG)
print floor(log(1000000000000000,10)) . "\n";
outputs 15, correct
print floor(log10(1000)) . "\n";
outputs 3, correct
print floor(log( 1000, 10 )) . "\n";
outputs 3, correct
r108284 used log( foo, 10) instead of log10() but that broke the continuous integration system which use Ubuntu :D
Version: 1.20.x
Severity: normal