1. It is suggested that you write your code in the following order:
2. Negative numbers are allowed.
3. You must catch the error where an object's "value" member has the potential to be
4. Constructor
Examples:
Fixed f(1.2345, 4) --> value = 12345, precision = 4
Fixed f(1.2345, 2) --> value = 123, precision = 2
Fixed f(1.2345, 0) --> value = 1, precision = 0
Fixed f(1.2345, 6) --> value = 1234500, precision = 6
You must do error checking on precision. Use the following algorithm:
5. Overloading of <<
Examples
To avoid imprecise results, DO NOT use your overloaded float cast operator.
(Hint: think of how to display the integer and fractional portions of the
Fixed number separately.)
6. setPrecision
Examples
You must do error checking on the precision argument. Use the following algorithm:
7. Assignment
Must be able to do:
Must be able to do:
Assume 2 for the precision of the float.
Assume no overflow for the float.
8. Cast from Fixed to float
There is no return type in the prototype
However, you must have a return statement in the function that returns
a float.
Example:
Note that the value and precision of "a" will NOT change.
9. Arithmetic (+, -, *, /)
Precision of the answer will have the precision of the operand with
the greater precision.
10. Trig and Power
Correction: "exp" function should be called "pow"
"pow" raises a Fixed to an int power.
--------
Last modified: