PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Richard Munroe   Rational   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Examples of rational number arithmetic
Class: Rational
Perform arithmetic operations on rational numbers
Author: By
Last change:
Date: 18 years ago
Size: 428 bytes
 

Contents

Class file image Download
<?php

include_once 'class.Rational.php' ;

$r = new Rational(1, 2) ;
$r1 = new Rational(1/3) ;

var_dump($r) ;
var_dump($r1) ;

var_dump(Rational::subtract($r1, $r)) ;
var_dump(Rational::add($r, $r1)) ;

$r = new Rational(2, 6) ;
$r->simplify() ;
var_dump($r) ;

$r = new Rational(.25) ;
$r1 = new Rational($r) ;

var_dump($r) ;
var_dump($r1) ;

var_dump(Rational::multiply($r, $r1)) ;
var_dump(Rational::divide($r, $r1)) ;
?>