Login   Register  
PHP Classes
elePHPant
Icontem

Rational: Perform arithmetic operations on rational numbers

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Info   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings  
2007-05-28 (7 years ago) RSS 2.0 feedNot yet rated by the usersTotal: 367 All time: 6,089 This week: 835Up
Version License Categories  
rational 1.0Custom (specified in a ...Math
Description Author  

This performs arithmetic operations using rational numbers.

Rational numbers are those numbers that can be represented as the ratio between two integer numbers. Any real number with a finite number decimal digits or that repeats a sequence of digits can be represented as a rational number.

This class can add, subtract, multiply, and divide rational numbers.

The results of the operations are also rational numbers, simplified to eliminate any common factors of the the numerator and denominator. This way the arithmetic operations are performed without loss of precision, a common failing of floating point arithemetic.

Innovation Award  
PHP Programming Innovation award nominee
February 2006
Number 4


Prize: One book of choice by O'Reilly
PHP supports all the kinds of arithmetic operations that can be performed between numbers. However, certain operations between rational numbers may result in values that loose precision because PHP represents the results as floating point values.

This class provides means to perform basic arithmetic operations between rational numbers, in a way that the results are also rational numbers, and so they do not loose precision.

Manuel Lemos
Picture of Richard Munroe
Name: Richard Munroe is available for providing paid consulting. Contact Richard Munroe .
Classes: 22 packages by
Country: United States United States
Age: 63
All time rank: 111 in United States United States
Week rank: 103 Down12 in United States United States Down
Innovation award
Innovation award
Nominee: 3x

Winner: 1x

  Files folder image Files  
File Role Description
Plain text file class.Rational.php Class Class file for rational numbers.
Accessible without login Plain text file example.php Example Examples of rational number arithmetic
Accessible without login HTML file license.txt Lic. Modified NetBSD License
Accessible without login Plain text file makedoc.sh Data Generate documentation using phpdoc

Downloadrational-2007-05-28.zip 3KB
Downloadrational-2007-05-28.tar.gz 3KB
Install with ComposerInstall with Composer
Needed packages  
Class DownloadWhy it is needed Dependency
Numerical Download .zip .tar.gz Several functions are required for conversion to rational form and simplifying rational numbers. Required
 Version Control Unique User Downloads Download Rankings  
 0%Total:367All time:6,089
 This week:0This week:835Up