You are here

public static function PHPExcel_Calculation_MathTrig::ROUNDDOWN in Loft Data Grids 7.2

Same name and namespace in other branches
  1. 6.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/MathTrig.php \PHPExcel_Calculation_MathTrig::ROUNDDOWN()

* ROUNDDOWN * * Rounds a number down to a specified number of decimal places * *

Parameters

float $number Number to round: * @param int $digits Number of digits to which you want to round $number * @return float Rounded Number

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/MathTrig.php, line 956

Class

PHPExcel_Calculation_MathTrig
PHPExcel_Calculation_MathTrig

Code

public static function ROUNDDOWN($number, $digits) {
  $number = PHPExcel_Calculation_Functions::flattenSingleValue($number);
  $digits = PHPExcel_Calculation_Functions::flattenSingleValue($digits);
  if (is_numeric($number) && is_numeric($digits)) {
    $significance = pow(10, (int) $digits);
    if ($number < 0.0) {
      return ceil($number * $significance) / $significance;
    }
    else {
      return floor($number * $significance) / $significance;
    }
  }
  return PHPExcel_Calculation_Functions::VALUE();
}