You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
archive.tmp contains 1056241 ip addresses, why does abbreviatedNumber say 1.1M when it should say 1.0M
My guess is it is not rounding down, it said 1.0 when it was just over 1M IP addresses in the file
The text was updated successfully, but these errors were encountered:
You're rounding to the nearest 1000, not to the nearest million. In any case this is neither a documentation issue, nor a bug in PHP. Please use some forum, such as StackOverflow, if you need programming help.
function abbreviateNumber($number) {
if ($number >= 1000000000) {
$abbreviated = number_format($number / 1000000000, 1) . 'B';
} elseif ($number >= 1000000) {
$abbreviated = number_format($number / 1000000, 1) . 'M';
} elseif ($number >= 1000) {
$abbreviated = number_format($number / 1000, 0) . 'K';
} else {
$abbreviated = $number;
}
return $abbreviated;
}
function countLines($filename) {
$lineCount = 0;
}
$filename = 'archive.tmp';
$lines = countLines($filename);
$roundedDown = floor($lines / 1000) * 1000;
$abbreviatedNumber = abbreviateNumber($roundedDown);
echo $abbreviatedNumber . "+ IP's LISTED";
archive.tmp contains 1056241 ip addresses, why does abbreviatedNumber say 1.1M when it should say 1.0M
My guess is it is not rounding down, it said 1.0 when it was just over 1M IP addresses in the file
The text was updated successfully, but these errors were encountered: