Forum archive 2000-2006

Michael Gage -

Michael Gage -

by Arnold Pizer -
Number of replies: 0 topic started 5/15/2002; 8:49:00 PM
last post 5/15/2002; 8:49:00 PM
userMichael Gage -  blueArrow
5/15/2002; 8:49:00 PM (reads: 1995, responses: 0)


    This object is designed to ease the use of fractions

Variables and Methods

        numerator   #numerator of fraction
denominator #denominator of fraction
    Arithmetic Methods  #these will all accept a scalar value or
#another fraction as an argument
        plus        #returns the sum of the fraction and argument
minus #returns fraction minus argument
subtractFrom #returns argument minus fraction
divBy #returns fraction divided by argument
divInto #returns argument divided by fraction
times #returns fraction times argument
compare #returns <, =, or > for the relation of fraction to argument
            pow     #returns fraction raised to argument, a given integer power
    Other methods

reduce #reduces to lowest terms, and makes sure denominator is positive
scalar #returns the scalar value numerator/denominator
print #prints the fraction
print_mixed #prints the fractionas a mixed number
print_inline #prints the fraction like this 2/3


    The fraction object stores two variables, numerator and denominator.    The basic
arithmatic methods listed above can be performed on a fraction, and it can return
its own
scalar value for use with functions expecting a scalar (ie, sqrt($frac->scalar) ).
File path = /ww/webwork/pg/lib/

<| Post or View Comments |>