PHP - Number: Working With FractionsTag: number, fraction Category: PHP Basicpost: 16 Mar 2008 read: 65 If you want to perform a mathematical operation involving fractions, you can use PEAR's Math_Fraction class as follows:
A fraction is a number in the form a/b and in this form, a is called the numerator and b is called the denominator. The denominator of a fraction can never be 0. Examples of fractions include 1/3, 19/7, and 1.5/3.5. A fraction here is expressed as an object and generated by passing the fraction's numerator and denominator as arguments to the class constructor. Two methods such as toString( ) and toFloat( ) take cares of displaying the fraction, either as a fraction or a floating-point value. |
| | Give Your Opinion | Recommend |
|

