Skip to content

Commit cdf6b22

Browse files
authored
Update number_helper.php
1 parent 017cdbd commit cdf6b22

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

system/Helpers/number_helper.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ function number_to_size($num, int $precision = 1, ?string $locale = null)
6969
*
7070
* @see https://simple.wikipedia.org/wiki/Names_for_large_numbers
7171
*
72-
* @param int|string $num
72+
* @param int|string $num Will be cast as int
73+
* @param int $precision [optional] The optional number of decimal digits to round to.
74+
* @param string $locale [optional]
7375
*
7476
* @return bool|string
7577
*/
@@ -91,19 +93,19 @@ function number_to_amount($num, int $precision = 0, ?string $locale = null)
9193
$generalLocale = substr($locale, 0, $underscorePos);
9294
}
9395

94-
if ($num > 1_000_000_000_000_000) {
96+
if ($num >= 1_000_000_000_000_000) {
9597
$suffix = lang('Number.quadrillion', [], $generalLocale);
9698
$num = round(($num / 1_000_000_000_000_000), $precision);
97-
} elseif ($num > 1_000_000_000_000) {
99+
} elseif ($num >= 1_000_000_000_000) {
98100
$suffix = lang('Number.trillion', [], $generalLocale);
99101
$num = round(($num / 1_000_000_000_000), $precision);
100-
} elseif ($num > 1_000_000_000) {
102+
} elseif ($num >= 1_000_000_000) {
101103
$suffix = lang('Number.billion', [], $generalLocale);
102104
$num = round(($num / 1_000_000_000), $precision);
103-
} elseif ($num > 1_000_000) {
105+
} elseif ($num >= 1_000_000) {
104106
$suffix = lang('Number.million', [], $generalLocale);
105107
$num = round(($num / 1_000_000), $precision);
106-
} elseif ($num > 1000) {
108+
} elseif ($num >= 1000) {
107109
$suffix = lang('Number.thousand', [], $generalLocale);
108110
$num = round(($num / 1000), $precision);
109111
}

0 commit comments

Comments
 (0)