Math_Fraction
[ class tree: Math_Fraction ] [ index: Math_Fraction ] [ all elements ]

Class: Math_FractionOp

Source Location: /Math_Fraction-0.4.1/FractionOp.php

Class Overview


Math_FractionOp: static class to operate on Math_Fraction objects


Author(s):

Version:

  • 0.4.1

Methods


Inherited Variables

Inherited Methods


Class Details

[line 31]
Math_FractionOp: static class to operate on Math_Fraction objects
  • Author: Kouber Saparev <kouber@php.net>
  • Version: 0.4.1
  • Access: public


[ Top ]


Method Detail

add   [line 96]

object Math_Fraction add( object $n1, object $n2, [ $return_simplified = true])

Returns the sum of two fractions: n = n1 + n2
  • Access: public

Parameters:

object   $n1   —  Math_Fraction
object   $n2   —  Math_Fraction
   $return_simplified   — 

[ Top ]

compare   [line 62]

int compare( object $n1, object $n2)

Compares two fractions.

if $n1 > $n2, returns 1, if $n1 == $n2, returns 0, if $n1 < $n2, returns -1

  • Access: public

Parameters:

object   $n1   —  Math_Fraction
object   $n2   —  Math_Fraction

[ Top ]

div   [line 169]

object Math_Fraction div( object $n1, object $n2, [ $return_simplified = true])

Returns the quotient of two fractions: n = n1 / n2
  • Access: public

Parameters:

object   $n1   —  Math_Fraction
object   $n2   —  Math_Fraction
   $return_simplified   — 

[ Top ]

floatToFraction   [line 295]

object Math_Fraction floatToFraction( float $f)

Converts float to fraction and try to keep the maximal possible precision.
  • Access: public

Parameters:

float   $f   — 

[ Top ]

gcd   [line 188]

int gcd( int $n1, int $n2)

Returns the greatest common divisor of two integers.
  • Access: public

Parameters:

int   $n1   — 
int   $n2   — 

[ Top ]

isFraction   [line 40]

boolean isFraction( $n)

Checks if a given object is an instance of PEAR::Math_Fraction
  • Access: public

Parameters:

   $n   — 

[ Top ]

lcm   [line 220]

int lcm( int $n1, int $n2)

Returns the least common multiple of two integers.
  • Access: public

Parameters:

int   $n1   — 
int   $n2   — 

[ Top ]

mult   [line 143]

object Math_Fraction mult( object $n1, object $n2, [ $return_simplified = true])

Returns the product of two fractions: n = n1 * n2
  • Access: public

Parameters:

object   $n1   —  Math_Fraction
object   $n2   —  Math_Fraction
   $return_simplified   — 

[ Top ]

raiseError   [line 368]

object PEAR::raiseError() raiseError( string $str)

An error capturing function.
  • Access: public

Parameters:

string   $str   — 

[ Top ]

reciprocal   [line 239]

object Math_Fraction reciprocal( object $n)

Returns the reciprocal value of a fraction: n = 1/n
  • Access: public

Parameters:

object   $n   —  Math_Fraction

[ Top ]

reduce   [line 282]

object Math_Fraction &reduce( &$n, object $n)

An alias of the Math_FractionOp::simplify() method.
  • Access: public

Parameters:

object   $n   —  Math_Fraction
   &$n   — 

[ Top ]

simplify   [line 258]

object Math_Fraction &simplify( &$n, object $n)

Returns the simplified value (reduction) of a fraction.
  • Access: public

Parameters:

object   $n   —  Math_Fraction
   &$n   — 

[ Top ]

stringToFraction   [line 339]

object Math_Fraction stringToFraction( string $str)

Converts string to fraction.
  • Access: public

Parameters:

string   $str   — 

[ Top ]

sub   [line 124]

object Math_Fraction sub( object $n1, object $n2, [ $return_simplified = true])

Returns the subtraction of two fractions: n = n1 - n2
  • Access: public

Parameters:

object   $n1   —  Math_Fraction
object   $n2   —  Math_Fraction
   $return_simplified   — 

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:07:36 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.