Overview

Namespaces

  • chippyash
    • Type
      • Exceptions
      • Interfaces
      • Number
        • Complex
        • Rational
      • String

Classes

  • AbstractRationalType
  • GMPRationalType
  • RationalType
  • RationalTypeFactory
  • Overview
  • Namespace
  • Class
  • Tree

Class AbstractRationalType

Abstract rational number type

chippyash\Type\AbstractType implements chippyash\Type\Interfaces\TypeInterface
Extended by chippyash\Type\AbstractMultiValueType
Extended by chippyash\Type\Number\Rational\AbstractRationalType implements chippyash\Type\Interfaces\RationalTypeInterface, chippyash\Type\Interfaces\NumericTypeInterface

Direct known subclasses

chippyash\Type\Number\Rational\GMPRationalType, chippyash\Type\Number\Rational\RationalType
Abstract
Namespace: chippyash\Type\Number\Rational
Located at Number/Rational/AbstractRationalType.php
Methods summary
public chippyash\Type\Number\Complex\ComplexType
# asComplex( )

Return the number as a Complex number i.e. n+0i

Return the number as a Complex number i.e. n+0i

Returns

chippyash\Type\Number\Complex\ComplexType
\chippyash\Type\Number\Complex\ComplexType

Implementation of

chippyash\Type\Interfaces\NumericTypeInterface::asComplex()
public chippyash\Type\Number\Rational\RationalType
# asRational( )

Return number as Rational number. NB, numerator and denominator will be caste as IntTypes

Return number as Rational number. NB, numerator and denominator will be caste as IntTypes

Returns

chippyash\Type\Number\Rational\RationalType
\chippyash\Type\Number\Rational\RationalType

Implementation of

chippyash\Type\Interfaces\NumericTypeInterface::asRational()
public chippyash\Type\Number\IntType
# asIntType( )

Return number as an IntType number. Will return floor(n/d)

Return number as an IntType number. Will return floor(n/d)

Returns

chippyash\Type\Number\IntType
\chippyash\Type\Number\IntType

Implementation of

chippyash\Type\Interfaces\NumericTypeInterface::asIntType()
public chippyash\Type\Number\FloatType
# asFloatType( )

Return number as a FloatType number.

Return number as a FloatType number.

Returns

chippyash\Type\Number\FloatType
\chippyash\Type\Number\FloatType

Implementation of

chippyash\Type\Interfaces\NumericTypeInterface::asFloatType()
public mixed
# numerator( )

Get the numerator

Get the numerator

Returns

mixed
mixed

Implementation of

chippyash\Type\Interfaces\RationalTypeInterface::numerator()
public mixed
# denominator( )

Get the denominator

Get the denominator

Returns

mixed
mixed

Implementation of

chippyash\Type\Interfaces\RationalTypeInterface::denominator()
public chippyash\Type\Number\Rational\RationalType
# abs( )

Return the absolute value of the number

Return the absolute value of the number

Returns

chippyash\Type\Number\Rational\RationalType
\chippyash\Type\Number\Rational\RationalType

Implementation of

chippyash\Type\Interfaces\NumericTypeInterface::abs()
public chippyash\Type\Number\Rational\RationalType
# negate( )

Negates the number

Negates the number

Returns

chippyash\Type\Number\Rational\RationalType
Fluent Interface

Implementation of

chippyash\Type\Interfaces\NumericTypeInterface::negate()
public string
# __toString( )

Magic method - convert to string Returns "<num>/<den>" or "<num>" if isInteger()

Magic method - convert to string Returns "<num>/<den>" or "<num>" if isInteger()

Returns

string
string

Overrides

chippyash\Type\AbstractMultiValueType::__toString()

Implementation of

chippyash\Type\Interfaces\TypeInterface::__toString()
public integer|float
# getAsNativeType( )

Get the basic PHP value of the object type properly In this case, the type is an int or float

Get the basic PHP value of the object type properly In this case, the type is an int or float

Returns

integer|float
int|float
public boolean
# isInteger( )

Is this Rational an expression of an integer, i.e. n/1

Is this Rational an expression of an integer, i.e. n/1

Returns

boolean
boolean
Methods inherited from chippyash\Type\AbstractMultiValueType
__clone(), __construct(), __invoke(), get(), set()
Chippyash Strong Types API documentation generated by ApiGen 2.8.0