summaryrefslogtreecommitdiffstats
path: root/inc/util.inc.php
diff options
context:
space:
mode:
authorSimon Rettberg2020-01-14 15:15:36 +0100
committerSimon Rettberg2020-01-14 15:15:36 +0100
commit79bffaece46a584997d4c782f94bfff1a720387b (patch)
tree107c43a94992e27a46e8938d793eddd55710dc89 /inc/util.inc.php
parent[sysconfig] AD/LDAP: Fix couple of html bugs (diff)
downloadslx-admin-79bffaece46a584997d4c782f94bfff1a720387b.tar.gz
slx-admin-79bffaece46a584997d4c782f94bfff1a720387b.tar.xz
slx-admin-79bffaece46a584997d4c782f94bfff1a720387b.zip
[inc/Util] Fix rounding based on OS bitness
Diffstat (limited to 'inc/util.inc.php')
-rw-r--r--inc/util.inc.php7
1 files changed, 6 insertions, 1 deletions
diff --git a/inc/util.inc.php b/inc/util.inc.php
index bddf0e45..6be06bf6 100644
--- a/inc/util.inc.php
+++ b/inc/util.inc.php
@@ -239,7 +239,12 @@ SADFACE;
*/
public static function readableFileSize($bytes, $decimals = -1, $shift = 0)
{
- $bytes = sprintf('%u', $bytes); // round doesn't reliably work for large floats
+ // round doesn't reliably work for large floats, pick workaround depending on OS
+ if (PHP_INT_SIZE === 4) {
+ $bytes = sprintf('%.0f', $bytes);
+ } else {
+ $bytes = sprintf('%u', $bytes);
+ }
static $sz = array('Byte', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB');
$factor = (int)floor((strlen($bytes) - 1) / 3);
if ($factor === 0) {