Class \Prado\Util\Math\TURational
TURational implements a fraction in the form of one unsigned integer \Prado\Util\Math\getNumerator divided by another unsigned integer \Prado\Util\Math\getDenominator.
TURational is a specialization of TRational and TRational has information about how these classes work.
INF is "4294967295/0" and NAN (Not A Number) has the denominator equal zero (to avoid a divide by zero error).
When setting a \Prado\Util\Math\setNumerator and \Prado\Util\Math\setDenominator, the PHP instance is checked if it is 32 bit or 64 bit. 64 Bit PHP can represent integers in the range [2147483648, 4294967295] as an integer, but on a 32 bit PHP instance, these high bit integers are converted to float to be more accurately represented.
The Rational data format is used by EXIF and, in particular, the GPS Image File Directory.
Class hierarchy
- \Prado\Util\Math\TURational
- \Prado\Util\Math\TRational implements ArrayAccess
Since: 4.3.0
public
static
|
|
public
|
getValue() : float
This returns the float value of the Numerator divided by the denominator.
Returns INF (Infinity) float value if the \Prado\Util\Math\getNumerator is 0xFFFFFFFF (4294967295) and \Prado\Util\Math\getDenominator is 0. Returns NAN (Not A Number) float value if the \Prado\Util\Math\getDenominator is zero. |
public
|
setDenominator(float|int|string $value) : TRational
This only accepts 0 and positive values. For 32 bit systems this accepts a float
to represent numbers larger than PHP_INT_MAX.
|
public
|
setNumerator(float|int|string $value) : TRational
This only accepts 0 and positive values. For 32 bit systems this accepts a float
to represent numbers larger than PHP_INT_MAX.
|
__construct, __toString, float2rational, getDenominator, getIsUnsigned, getNumerator, getValue, offsetExists, offsetGet, offsetSet, offsetUnset, setDenominator, setNumerator, setValue, toArray |
\Prado\Util\Math\TRational::DEFAULT_TOLERANCE, \Prado\Util\Math\TRational::DENOMINATOR, \Prado\Util\Math\TRational::NUMERATOR |