| @@ 191-205 (lines=15) @@ | ||
| 188 | } |
|
| 189 | ||
| 190 | if (!function_exists('trunc')) { |
|
| 191 | function trunc($floatnumber) { |
|
| 192 | // truncates a floating-point number at the decimal point |
|
| 193 | // returns int (if possible, otherwise float) |
|
| 194 | if ($floatnumber >= 1) { |
|
| 195 | $truncatednumber = floor($floatnumber); |
|
| 196 | } elseif ($floatnumber <= -1) { |
|
| 197 | $truncatednumber = ceil($floatnumber); |
|
| 198 | } else { |
|
| 199 | $truncatednumber = 0; |
|
| 200 | } |
|
| 201 | if ($truncatednumber <= pow(2, 30)) { |
|
| 202 | $truncatednumber = (int) $truncatednumber; |
|
| 203 | } |
|
| 204 | return $truncatednumber; |
|
| 205 | } |
|
| 206 | } |
|
| 207 | ||
| 208 | if (!function_exists('CastAsInt')) { |
|
| @@ 53-67 (lines=15) @@ | ||
| 50 | * |
|
| 51 | * @return float|int returns int (if possible, otherwise float) |
|
| 52 | */ |
|
| 53 | public static function trunc($floatnumber) { |
|
| 54 | if ($floatnumber >= 1) { |
|
| 55 | $truncatednumber = floor($floatnumber); |
|
| 56 | } elseif ($floatnumber <= -1) { |
|
| 57 | $truncatednumber = ceil($floatnumber); |
|
| 58 | } else { |
|
| 59 | $truncatednumber = 0; |
|
| 60 | } |
|
| 61 | if (self::intValueSupported($truncatednumber)) { |
|
| 62 | $truncatednumber = (int) $truncatednumber; |
|
| 63 | } |
|
| 64 | return $truncatednumber; |
|
| 65 | } |
|
| 66 | ||
| 67 | /** |
|
| 68 | * @param int|null $variable |
|
| 69 | * @param int $increment |
|
| 70 | * |
|