## Forum archive 2000-2006

### Michael Gage - Fraction.pm ### Michael Gage - Fraction.pm

by Arnold Pizer -
Number of replies: 0 Fraction.pm topic started 5/15/2002; 8:49:00 PMlast post 5/15/2002; 8:49:00 PM Michael Gage - Fraction.pm 5/15/2002; 8:49:00 PM (reads: 1995, responses: 0)

### Fraction

    This object is designed to ease the use of fractions

#### Variables and Methods

    Variables
        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

#### Synopsis

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

<| Post or View Comments |>