Skip to content

Commit

Permalink
When converting bits its to the power of 1000 not 1024 (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexjustesen authored Oct 23, 2022
1 parent ba2ae9f commit 71f0efb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
function formatBits(int $bits, $precision = 2)
{
if ($bits > 0) {
$i = floor(log($bits) / log(1024));
$i = floor(log($bits) / log(1000));

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

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

return 0;
Expand Down

0 comments on commit 71f0efb

Please sign in to comment.