I would like to convert Bytes into TB and I found this calculator:
function byte_umrechner($bytes) {
if ($bytes > pow(2, 10)) {
if ($bytes > pow(2, 40)) {
$size = number_format(($bytes / pow(2, 40)), 4, ',', '');
$size. = " TB";
return $size;
}
if ($bytes > pow(2, 30)) {
$size = number_format(($bytes / pow(2, 30)), 2, ',', '');
$size. = " GB";
return $size;
}
elseif($bytes > pow(2, 20)) {
$size = number_format(($bytes / pow(2, 20)), 2, ',', '');
$size. = " MB";
return $size;
} else {
$size = number_format(($bytes / pow(2, 10)), 2, ',', '');
$size. = " KB";
return $size;
}
} else {
$size = (string) $bytes.
" Bytes";
return $size;
}
}
echo byte_umrechner(1099511627776);
My result in this case is 1024,00 GB
But it should actually show 1TB
because 1099511627776 Bytes
actually are exactly 1TB
.