Bitrix-D7  20.5.0
pricemaths.php
См. документацию.
1 <?php
2 
3 namespace Bitrix\Sale;
4 
5 use Bitrix\Main;
6 
7 class PriceMaths
8 {
9  private static $valuePrecision = null;
10 
11  /**
12  * @param $value
13  *
14  * @return float
15  * @throws Main\ArgumentNullException
16  */
17  public static function roundPrecision($value)
18  {
19  if (!isset(self::$valuePrecision))
20  {
21  self::$valuePrecision = (int)Main\Config\Option::get('sale', 'value_precision');
22  if (self::$valuePrecision <= 0)
23  {
24  self::$valuePrecision = 2;
25  }
26  }
27 
28  return round(doubleval($value), self::$valuePrecision);
29  }
30 
31  /**
32  * @deprecated Use \Bitrix\Sale\PriceMaths::roundPrecision instead it
33  *
34  * @param $price
35  * @param $currency
36  *
37  * @return float
38  */
39  public static function roundByFormatCurrency($price, $currency)
40  {
41  return floatval(SaleFormatCurrency($price, $currency, false, true));
42  }
43 }
static get($moduleId, $name, $default="", $siteId=false)
Returns a value of an option.
static roundByFormatCurrency($price, $currency)
Definition: pricemaths.php:39
static roundPrecision($value)
Definition: pricemaths.php:17