Skip to content

Commit 71f0efb

Browse files
authored
When converting bits its to the power of 1000 not 1024 (alexjustesen#70)
1 parent ba2ae9f commit 71f0efb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

app/helpers.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
function formatBits(int $bits, $precision = 2)
55
{
66
if ($bits > 0) {
7-
$i = floor(log($bits) / log(1024));
7+
$i = floor(log($bits) / log(1000));
88

99
$sizes = ['B', 'Kb', 'Mb', 'Gb', 'Tb', 'Pb', 'Eb', 'Zb', 'Yb'];
1010

11-
return sprintf('%.02F', round($bits / pow(1024, $i), $precision)) * 1 .' '.@$sizes[$i];
11+
return sprintf('%.02F', round($bits / pow(1000, $i), $precision)) * 1 .' '.@$sizes[$i];
1212
}
1313

1414
return 0;

0 commit comments

Comments
 (0)