In a sensible language ( any of C/Java/Python) write a program which correctly calculates add, subtract,...

Question:

In a sensible language ( any of C/Java/Python) write a program which correctly calculates add, subtract, multiply and divide using our ‘minifloat’ binary format using an algorithm you code yourself.  Some details:

Your program only needs to work on two ‘numbers’ at a time, read those in from a text file – failure to read those values from a text file will result in a grade of 0.   For each ‘number’ store the sign, exponent and mantissa separately.   You can hard code your examples.

E.g.

Struct minifloat{

Int sign;  // sign, actually 1 bit

Int exponent; // this is the exponent and is 4 bits long (0-15)

Int mantissa;  //this is the fraction part and is 3bits long (0-7), but I would keep the 1. Stored explicitly, so it becomes 0-15 and 4 digits long.

}

Show testing for all 4 (add, sub, mul, div) with at least 3 examples (and compare to results you do by hand).

Make sure you are error checking for NAN and +/- 0.

Note:  This is an obviously contrived example, the intent is to force you to think about the algorithm, not to make software that anyone would ever want to use.

The numbers should be from a separate text file.

Similar Solved Questions

Develop   an   original   example   of   an   intercultural   communication   misinterpretation   in   a   job   interview
Develop   an   original   example   of   an   intercultural   communication   misinterpretation   in   a   job   interview   situation   that   could&...
How do you simplify \frac { 3t - 3} { t } \times \frac { 6t ^ { 2} } { 15t - 15}?
How do you simplify \frac { 3t - 3} { t } \times \frac { 6t ^ { 2} } { 15t - 15}?...
3. (5 points) A round 10 m-diameter pool can be emptied by unplugging the pipe (5...
3. (5 points) A round 10 m-diameter pool can be emptied by unplugging the pipe (5 cm diameter and 15 m length) at the bootom of the pool as shown in Fig. 3. The wa- evel ter surface in the pool is at the 2 m l above the ground. Disregarding all the frie- tional effects and neglecting the velocity at...