PHP Classes

Rational: Perform arithmetic operations on rational numbers

Recommend this page to a friend!
  Info   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 401 This week: 1All time: 6,555 This week: 560Up
Version License Categories
rational 1.0Custom (specified...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: 73
All time rank: 112 in United States United States
Week rank: 106 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
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:401
This week:1
All time:6,555
This week:560Up