当前位置: 首页>>代码示例>>PHP>>正文


PHP PHPExcel_Calculation_MathTrig::MROUND方法代码示例

本文整理汇总了PHP中PHPExcel_Calculation_MathTrig::MROUND方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPExcel_Calculation_MathTrig::MROUND方法的具体用法?PHP PHPExcel_Calculation_MathTrig::MROUND怎么用?PHP PHPExcel_Calculation_MathTrig::MROUND使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PHPExcel_Calculation_MathTrig的用法示例。


在下文中一共展示了PHPExcel_Calculation_MathTrig::MROUND方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: DOLLAR

 /**
  * 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)..
  *
  * @param	float	$value			The value to format
  * @param	int		$decimals		The number of digits to display to the right of the decimal point.
  *									If decimals is negative, number is rounded to the left of the decimal point.
  *									If you omit decimals, it is assumed to be 2
  * @return	string
  */
 public static function DOLLAR($value = 0, $decimals = 2)
 {
     $value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
     $decimals = is_null($decimals) ? 0 : PHPExcel_Calculation_Functions::flattenSingleValue($decimals);
     // Validate parameters
     if (!is_numeric($value) || !is_numeric($decimals)) {
         return PHPExcel_Calculation_Functions::NaN();
     }
     $decimals = floor($decimals);
     if ($decimals > 0) {
         return money_format('%.' . $decimals . 'n', $value);
     } else {
         $round = pow(10, abs($decimals));
         if ($value < 0) {
             $round = 0 - $round;
         }
         $value = PHPExcel_Calculation_MathTrig::MROUND($value, $round);
         //	The implementation of money_format used if the standard PHP function is not available can't handle decimal places of 0,
         //		so we display to 1 dp and chop off that character and the decimal separator using substr
         return substr(money_format('%.1n', $value), 0, -2);
     }
 }
开发者ID:EmmanuelTaborda2015,项目名称:kyron_modificado,代码行数:34,代码来源:TextData.php

示例2: DOLLAR

 /**
  * 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)..
  *
  * @param    float    $value            The value to format
  * @param    int        $decimals        The number of digits to display to the right of the decimal point.
  *                                    If decimals is negative, number is rounded to the left of the decimal point.
  *                                    If you omit decimals, it is assumed to be 2
  * @return    string
  */
 public static function DOLLAR($value = 0, $decimals = 2)
 {
     $value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
     $decimals = is_null($decimals) ? 0 : PHPExcel_Calculation_Functions::flattenSingleValue($decimals);
     // Validate parameters
     if (!is_numeric($value) || !is_numeric($decimals)) {
         return PHPExcel_Calculation_Functions::NaN();
     }
     $decimals = floor($decimals);
     $mask = '$#,##0';
     if ($decimals > 0) {
         $mask .= '.' . str_repeat('0', $decimals);
     } else {
         $round = pow(10, abs($decimals));
         if ($value < 0) {
             $round = 0 - $round;
         }
         $value = PHPExcel_Calculation_MathTrig::MROUND($value, $round);
     }
     return PHPExcel_Style_NumberFormat::toFormattedString($value, $mask);
 }
开发者ID:oalkhanishvili,项目名称:track2,代码行数:33,代码来源:TextData.php


注:本文中的PHPExcel_Calculation_MathTrig::MROUND方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。