Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields
Division Class Reference

Public Member Functions

 getExactDivision ($dividend, $divisor)
 

Data Fields

const DIVIDE_EPSILON = 10000
 

Detailed Description

Division library

@api

Since
100.0.2

Definition at line 14 of file Division.php.

Member Function Documentation

◆ getExactDivision()

getExactDivision (   $dividend,
  $divisor 
)

Returns the floating point remainder (modulo) of the division of the arguments

Parameters
float | int$dividend
float | int$divisor
Returns
float|int

Definition at line 28 of file Division.php.

29  {
30  $epsilon = $divisor / self::DIVIDE_EPSILON;
31 
32  $remainder = fmod($dividend, $divisor);
33  if (abs($remainder - $divisor) < $epsilon || abs($remainder) < $epsilon) {
34  $remainder = 0;
35  }
36 
37  return $remainder;
38  }

Field Documentation

◆ DIVIDE_EPSILON

const DIVIDE_EPSILON = 10000

Const for correct dividing decimal values

Definition at line 19 of file Division.php.


The documentation for this class was generated from the following file: