1 answer

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.


Answers

  1. Using Python open() function to read the file in readbinary mode
  2. Cretae IF condition statement to verify input is number or not , if it is number then proceed
  3. Convert input number into binary using python's bin() function
  4. Create Logical Expretion for ADDITIOn,SUBRACTION, operations
  5. Then use bitwise OR,XOR and AND operator to operations for each bit values
  6. Store result in rective variables
.

Similar Solved Questions

1 answer
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&...
1 answer
If an investor bought a 6% annual coupon bond for $1020 and sold it 2 years...
if an investor bought a 6% annual coupon bond for $1020 and sold it 2 years later for $1080, the annual rate of return on her 2-year investment will be a)10.65% b)17.65% c)11.76% d)8.47%...
1 answer
Which of the following is an example of a quantity control? Select one: O a. employment...
Which of the following is an example of a quantity control? Select one: O a. employment insurance b. the minimum wage O C. limits on the number of cod that can be caught off the coast of Newfoundland O d. the medicare payment to physicians Next page iz Friday March 27 80 Jump to. ° Ch 12 Assignm...
1 answer
F(t) 18) Make a sketch of the time domain function f(t) (t-1)us(t) on the grid provided. Label key features and values to communicate the exact details f the function f(t) 18) Make a sketch of t...
f(t) 18) Make a sketch of the time domain function f(t) (t-1)us(t) on the grid provided. Label key features and values to communicate the exact details f the function f(t) 18) Make a sketch of the time domain function f(t) (t-1)us(t) on the grid provided. Label key features and values to communicat...
1 answer
15 Random vanables ( 21, 2,... xs} are taken from a normally distributed Population with mean...
15 Random vanables ( 21, 2,... xs} are taken from a normally distributed Population with mean U and Varrance 6² - Assuming that they are all indopondant. Wnte down an expression of thes is rev which has the following pdfs. (0 N(0, 1) (ii) X266) (1) F (6,7) (1) T (4)...
1 answer
A physical inventory of Liverpool Company taken at December 31 reveals the following. Per Unit Units...
A physical inventory of Liverpool Company taken at December 31 reveals the following. Per Unit Units Cost Market 353 268 334 212 $108 129 104 70 $116 119 113 60 Item Car audio equipment Speakers Stereos Amplifiers Subwoofers Security equipment Alarms Locks Cameras Binocular equipment Tripods Stabili...
1 answer
How do you solve #3x (8x-1)(x+9)=0#?
How do you solve #3x (8x-1)(x+9)=0#?...
1 answer
You have a lens whose focal length is -6.11 cm. You place an object on the...
You have a lens whose focal length is -6.11 cm. You place an object on the axis of the lens at a distance of 12.1 cm from it. How far is the object's image from the lens? Enter the answer as a positive quantity. image distance: cm If it can be determined, is the image real or virtual? O cannot b...
1 answer
In a recent poll, 45% of survey respondents said that, if they only had one child,...
In a recent poll, 45% of survey respondents said that, if they only had one child, they would prefer the child to be a boy. Suppose you conducted a survey of 160 randomly selected students on your campus and find that 82 of them would prefer a boy. Complete parts (a) and (b) below. Click here to vie...
1 answer
In a small country, the demand curve is given as: Q=100-5P, supply curve: Q=3P-12, and the...
In a small country, the demand curve is given as: Q=100-5P, supply curve: Q=3P-12, and the world price is $10. What is the social surplus under free trade? If the government impose a $2/unit tariff on the good, what is the deadweight loss? Show the change in equilibrium and deadweight loss on a grap...
1 answer
Question 17 (4 points) Which of the following is an acetal? он OH OH -он OCH...
Question 17 (4 points) Which of the following is an acetal? он OH OH -он OCH осн, OCH Question 18 (4 points) Predict the product(s) for the following reaction series: HO 1) NaH Nao w HO Question 19 (4 points) Which of the following statements is true? Aromat...
1 answer
Appraise ways in which your nursing practice (patient care, education, research, administration, etc.) has been influenced...
Appraise ways in which your nursing practice (patient care, education, research, administration, etc.) has been influenced by nursing (or borrowed) theory....
1 answer
(11% 523,000). e. None of these 11. On a particular Saturday. Tom h ated to paint...
(11% 523,000). e. None of these 11. On a particular Saturday. Tom h ated to paint a room in his work that day. If Tom works, he must hire a pain hiring the painter: a. Tom must eam more than $158 if he is in the 24% marginal b. Tom must earn at least 158 if he is in the 32% marginal tax e. Tom must ...
1 answer
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}#?...
1 answer
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...
1 answer
Complete this program, by adding a function called mag( ) to calculate the magnitude of a...
Complete this program, by adding a function called mag( ) to calculate the magnitude of a vector. You'll need to add a prototype before main( ), and the implementation (header & body) of the function after main( ); reminder: mag = sqrt (x 2 + y 2) Calling it with something like:   ...
1 answer
Analysis of algorithms
The square of a matrix A is its product with itself, AA.(a) Show that ve multiplications are sufcient to compute the square of a 2 2 matrix.What is wrong with the following algorithm for computing the square of an n n matrix??Use a divide-and-conquer approach as in Strassen's algorithm, except t...
1 answer
The Federal Reserve Bank (FED) is the single most influence on the cost of supply of...
The Federal Reserve Bank (FED) is the single most influence on the cost of supply of money for real estate loans. It is the link between America's private financial institutions and the taxing and spending policies of the federal government. Please consider the last 5 years and in your opinion, ...
1 answer
What are the 4P's in Corporate Governance? Explain each item. Lastly, Is there a relationship between...
What are the 4P's in Corporate Governance? Explain each item. Lastly, Is there a relationship between Moral with that Mission and Vision? Elaborate them Thankyou so much....