200k views
4 votes
Pseudocode of creating a program to convert to IEEE 754 to a real number

1 Answer

3 votes

Answer:

  • Step1: Check If the number is Positive or Negative.
  • Step2: If it is positive then save the sign of it as 0.
  • Step3: If it is negative then save the sign of it as 1.
  • Step4: Covert the negative number to Positive.
  • Step5: Convert the IEEE 754 to Binary.
  • Step6: convert the integer part into binary form
  • Step7: Convert fractional part into binary form
  • Step8: To convert Integer part, Devide the number by 2 and note down the reminder and Keep deviding unless dividend is less than 2
  • Step9: copy all the reminders together
  • Step10: Multiply decimal part by 2 unless fractional part is 0.
  • Step11: By noting down integral part, keep multiplying decimal part by new value of 2 untill perfect number is reached.
  • Step6: Find the Mantissa.
  • Step7: Concatinate the Sign, exponent and the mantissa.

Step-by-step explanation:

For Example : 20.75

First step (converting 50 (in base 10) to binary):

  • No is Positive
  • By dividing 20 by 2, which gives 10 with no remainder 0.
  • Now Devide 10 by 2, which gives 5 with a remainder of 0.
  • Now Devide 5 by 2, which gives 2 the reminder as 1
  • Now Devide 2 by 2, which gives 1 with reminder as 0
  • Now devide 1 by 2, which gives 0 with reminder as 1
  • We read the result from bottom to top which is 10100

Second part is to convert 0.75 to binary:

  • We have to multiply 0.75 by 2, which gives 1.5. We keep only the integer part, which is 1.
  • Now, we do 1.5 - 1, which gives 0.5. Now, We multiply 0.5 by 2, which gives 1.
  • Now we do 1 - 1, which gives 0.
  • Reading from Top to bottom will give 110

Final Answer is : 10100.110

User La Carbonell
by
5.0k points