Computer Organization Lab #5: Rational

  1. Implement the functions defined in Rational.h that support operations on rational numbers (fractions). You do not need to worry about supporting negative values. You should ensure if an attempt is made to initialize a Rational with a denominator of zero, a denominator of one is used instead.

  2. Notice that the functions in Rational.h accept their Rational parameters by value. Disassemble the object file produced by the compiler and see if you can figure out how Open Watcom is expecting such parameters to be delivered.

  3. Using Euclid's Algorithm for finding the greatest common divisor of two integers, modify your Rational_initialize so that it forces the rational number to be put into reduced form.

  4. OPTIONAL: Add support for negative rationals.

Submit your final Rational.c to Moodle. Include in comments your observations from part #2 above.


Last Revised: 2017-03-16
© Copyright 2017 by Peter C. Chapin <PChapin@vtc.vsc.edu>