You are here

public static function PHPExcel_Calculation_MathTrig::MROUND 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::MROUND()

* MROUND * * Rounds a number to the nearest multiple of a specified value * *

Parameters

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

1 call to PHPExcel_Calculation_MathTrig::MROUND()
PHPExcel_Calculation_TextData::DOLLAR in vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/TextData.php
* DOLLAR * * This function converts a number to text using currency format, with the decimals rounded to the specified place. * The format used is $#,##0.00_);($#,##0.00).. * *

File

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

Class

PHPExcel_Calculation_MathTrig
PHPExcel_Calculation_MathTrig

Code

public static function MROUND($number, $multiple) {
  $number = PHPExcel_Calculation_Functions::flattenSingleValue($number);
  $multiple = PHPExcel_Calculation_Functions::flattenSingleValue($multiple);
  if (is_numeric($number) && is_numeric($multiple)) {
    if ($multiple == 0) {
      return 0;
    }
    if (self::SIGN($number) == self::SIGN($multiple)) {
      $multiplier = 1 / $multiple;
      return round($number * $multiplier) / $multiplier;
    }
    return PHPExcel_Calculation_Functions::NaN();
  }
  return PHPExcel_Calculation_Functions::VALUE();
}