You are here

public function Fraction::reciprocate in Fraction 7

Reciprocate the fraction.

Return value

Fraction Returns this Fraction object.

File

./fraction.class.inc, line 291
Fraction class

Class

Fraction
@file Fraction class

Code

public function reciprocate() {

  // Get the numerator and denominator, but flipped.
  $numerator = $this
    ->getDenominator();
  $denominator = $this
    ->getNumerator();

  // Save the numerator and denominator.
  $this
    ->setNumerator($numerator);
  $this
    ->setDenominator($denominator);
  return $this;
}