mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 09:35:49 +02:00
Use 10 based prefixes for byte sizes instead of 2-based
This way we are consistent with the way symfony interprets the prefixes
This commit is contained in:
parent
e0635f7ead
commit
5a19024bec
2 changed files with 4 additions and 3 deletions
|
@ -160,7 +160,7 @@ class AttachmentManager
|
||||||
|
|
||||||
$sz = 'BKMGTP';
|
$sz = 'BKMGTP';
|
||||||
$factor = (int) floor((strlen((string) $bytes) - 1) / 3);
|
$factor = (int) floor((strlen((string) $bytes) - 1) / 3);
|
||||||
|
//Use real (10 based) SI prefixes
|
||||||
return sprintf("%.{$decimals}f", $bytes / 1024 ** $factor).@$sz[$factor];
|
return sprintf("%.{$decimals}f", $bytes / 1000 ** $factor).@$sz[$factor];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,6 +119,7 @@ final class FormatExtension extends AbstractExtension
|
||||||
{
|
{
|
||||||
$size = ['B','kB','MB','GB','TB','PB','EB','ZB','YB'];
|
$size = ['B','kB','MB','GB','TB','PB','EB','ZB','YB'];
|
||||||
$factor = floor((strlen((string) $bytes) - 1) / 3);
|
$factor = floor((strlen((string) $bytes) - 1) / 3);
|
||||||
return sprintf("%.{$precision}f", $bytes / pow(1024, $factor)) . ' ' . @$size[$factor];
|
//We use the real (10 based) SI prefix here
|
||||||
|
return sprintf("%.{$precision}f", $bytes / (1000 ** $factor)) . ' ' . @$size[$factor];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue