https://bugzilla.wikimedia.org/show_bug.cgi?id=33571
Web browser: ---
Bug #: 33571
Summary: Language::formatBitrate() give wrong result on Mac OS
X
Product: MediaWiki
Version: 1.19-svn
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: Unprioritized
Component: General/Unknown
AssignedTo: [email protected]
ReportedBy: [email protected]
Classification: Unclassified
Language::formatBitrate( 1000000000000000 ) gives '1,000Tbps' when it should be
'1Pbps'.
The end result is 'languages/LanguageTest.php' test suite gives a failure:
1) 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
--
Configure bugmail: https://bugzilla.wikimedia.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
You are on the CC list for the bug.
_______________________________________________
Wikibugs-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l