public static function PHPExcel_Calculation_Financial::DOLLARDE in Loft Data Grids 7.2
Same name and namespace in other branches
- 6.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/Financial.php \PHPExcel_Calculation_Financial::DOLLARDE()
* DOLLARDE * * Converts a dollar price expressed as an integer part and a fraction * part into a dollar price expressed as a decimal number. * Fractional dollar numbers are sometimes used for security prices. * * Excel Function: * DOLLARDE(fractional_dollar,fraction) * * @access public * @category Financial Functions *
Parameters
float $fractional_dollar Fractional Dollar: * @param integer $fraction Fraction * @return float
File
- vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Calculation/ Financial.php, line 1079
Class
- PHPExcel_Calculation_Financial
- PHPExcel_Calculation_Financial
Code
public static function DOLLARDE($fractional_dollar = Null, $fraction = 0) {
$fractional_dollar = PHPExcel_Calculation_Functions::flattenSingleValue($fractional_dollar);
$fraction = (int) PHPExcel_Calculation_Functions::flattenSingleValue($fraction);
// Validate parameters
if (is_null($fractional_dollar) || $fraction < 0) {
return PHPExcel_Calculation_Functions::NaN();
}
if ($fraction == 0) {
return PHPExcel_Calculation_Functions::DIV0();
}
$dollars = floor($fractional_dollar);
$cents = fmod($fractional_dollar, 1);
$cents /= $fraction;
$cents *= pow(10, ceil(log10($fraction)));
return $dollars + $cents;
}