Advertisement
Guest User

Untitled

a guest
Dec 18th, 2018
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. # Single precision floating point binary calculation process
  2.  
  3. Exercise: Convert 469.357 to a raw binary floating point representation
  4.  
  5. # Sign
  6. 0 (Because 0 if positive, 1 if negative)
  7.  
  8. ==> Sign = 0
  9.  
  10. # Exponent and Mantissa
  11. ### Convert the whole part into binary (WholeBinary)
  12. 469 / 2 = 234 1 (Because 469 / 2 has a reminder (atlikums) = 1)
  13. 234 / 2 = 117 0
  14. 117 / 2 = 58 1
  15. 58 / 2 = 29. 0
  16. 29 / 2 = 14. 1
  17. 14 / 2 = 7. 0
  18. 7 / 2 = 3. 1
  19. 3 / 2 = 1 1
  20. 1 / 2 = 0 1
  21.  
  22. WholeBinary = 111010101 (Read from bottom up)
  23.  
  24. ### Convert the fraction into binary (FractionBinary)
  25. 0.357 * 2 = 0.714 0 (If you multiply by 2 and the result is larger than 1, then write down 1, otherwise 0)
  26. 0.714 * 2 = 1.428 1
  27. 0.428 * 2 = 0.856 0 (Once you go over one in the results, remove the one, e.g. 1.428 -> 0.428)
  28. 0.856 * 2 = 1.712 1
  29. …..
  30. (Continue till you’re out of space or smth - enough to later fill all 32 bits including mantissa and sign)
  31.  
  32. FractionBinary = 010110110110010
  33.  
  34. ### Convert the binary number into a normalized binary scientific notation (e.g. 1.0000010101 * 2^12)
  35. NumberBinary = 111010101 . 010110110110010 (WholeBinary . FractionBinary)
  36. NumberBinaryScientific = 1 . 11010101010110110110010 * 2 ^ 8 (NumberBinary in scientific notation)
  37.  
  38. ==> Mantissa = 11010101010110110110010 (NumberBinaryScientific without the leading zero)
  39. ==> Exponent = 8 + 127 = 135 = 10000111 (NumberBinaryScientific exponent + 127 in binary)
  40.  
  41. # All together
  42. Floating binary format = Sign Exponent Mantissa
  43.  
  44. ==> Full Single-precision floating binary = 0 10000111 11010101 010110110110010
  45. ==>Online converter result = 0 10000111 11010101 010110110110010
  46.  
  47. Conclusion - you did it correctly!
  48.  
  49. ### Sidenote
  50. Online converter here = https://www.exploringbinary.com/floating-point-converter/
  51. Use "Single precision" and "Raw binary format"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement