| 1 |
<?php |
| 2 |
|
| 3 |
namespace TablePress\PhpOffice\PhpSpreadsheet\Calculation\MathTrig; |
| 4 |
|
| 5 |
use TablePress\PhpOffice\PhpSpreadsheet\Calculation\ArrayEnabled; |
| 6 |
|
| 7 |
class Trunc |
| 8 |
{ |
| 9 |
use ArrayEnabled; |
| 10 |
|
| 11 |
/** |
| 12 |
* TRUNC. |
| 13 |
* |
| 14 |
* Truncates value to the number of fractional digits by number_digits. |
| 15 |
* This will probably not be the precise result in the unlikely |
| 16 |
* event that the number of digits to the left of the decimal |
| 17 |
* plus the number of digits to the right exceeds PHP_FLOAT_DIG |
| 18 |
* (or possibly that value minus 1). |
| 19 |
* Excel is unlikely to do any better. |
| 20 |
* |
| 21 |
* @param null|array<mixed>|float|string $value Or can be an array of values |
| 22 |
* @param array<mixed>|float|int|string $digits Or can be an array of values |
| 23 |
* |
| 24 |
* @return array<mixed>|float|string Truncated value, or a string containing an error |
| 25 |
* If an array of numbers is passed as an argument, then the returned result will also be an array |
| 26 |
* with the same dimensions |
| 27 |
*/ |
| 28 |
public static function evaluate($value = 0, $digits = 0) |
| 29 |
{ |
| 30 |
if (is_array($value) || is_array($digits)) { |
| 31 |
return self::evaluateArrayArguments([self::class, __FUNCTION__], $value, $digits); |
| 32 |
} |
| 33 |
|
| 34 |
return Round::down($value, $digits); |
| 35 |
} |
| 36 |
} |
| 37 |
|