Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How would you solve this within Python? Please help Barebones file: https://drive.google.com/open?id=15Q9fKXuGaipijyw0Wh8wQyEiZjdnud18 Part I: Convert Decimal Format to Binary Fixed-point Format (20 points) Part II:

How would you solve this within Python? Please help

image text in transcribed

"Barebones" file:

https://drive.google.com/open?id=15Q9fKXuGaipijyw0Wh8wQyEiZjdnud18

Part I: Convert Decimal Format to Binary Fixed-point Format (20 points) Part II: Binary Fixed-point Format to Floating-point Format (20 points) Write a function decimal.to.fixed.point ) that takes only one argument, a string called value that contains a decimal number that could be positive or negative and which includes a fractional part. The function converts the decimal number into its fixed-point binary representation and returns the new representation. The function should generate exactly 23 digits to the right of the radix point. More on this below Write a function fixed.point.to.floating.point () that takes only one argument, a string called value that contains a binary fixed-point number with exactly 23 digits to the right of the radix point. The function con- verts the fixed-point binary number into its 32-bit floating-point representation and returns the new representation as a string of 0' and '1' characters. Remember that the exponent must have 8 digits and the mantissa 23 Therefore, if the computed exponent in binary form has fewer than 8 bits, prepend as many zeroes as needed to make the exponent 8 bits. Likewise, if the mantissa has fewer than 23 digits, append zeroes as needed to make the mantissa 23 bits CSE 101 -Fall 2017 Lab #10 Page 1 You may assume that only a negative sign might appear at the start of a number, never a positive sign. You might find the following Python functions useful index (): https://www.tutorialspoint.com/python/string_index.htm replace): https://www.tutorialspoint.com/python/string_replace.htm Here is the general idea of how to perform the conversion. First, separate off the whole number portion of the value (i.e., those digits to the left of the decimal point) and convert that part into binary. (Hint: use split() and bin ).) Then, separate off the fractional part (i.e., those digits to the right of the decimal point) and convert that part into binary using the multiplication algorithm covered on slide 44 of the Unit 10 lecture notes You should perform exactly 23 multiplications by the number 2 in order to generate the needed 23 digits. Remember: CodeLoad has additional tests for you to try! Upload your code there and see how your code matches up against harder tests. You may assume that only a negative sign might appear at the start of a number, never a positive sign. CSE 101 -Fall 2017 Lab #10 Page 2 You might find the following Python functions useful bin(): https://docs.python.org/Mibrary/functions.html#bin int(): https://docs.python.org/Mibrary/functions.html#int float ( ) : https://docs.python.org/3/library/functions.html#float . Split ( ) : https://docs.python.org/3.6/library/stdtypes.html#str split (Hint: split on , . ,) Function Call fixed.point.to.floating.point ('-1100.00100000000000000000000') Return Value 11000001010000100000000000000000' Function Call fixed point.to.floating-point ('-0.00011100001010001111010') Return Value 10111101111000010100011110100000' Function Call fixed point.to floating.point ('-0.00000000000000000000000') Return Value 10000000000000000000000000000000' Function Call fixed.point.to.floating-point ('1111011.01110100111010100100101') Return Value 01000010111101101110100111010100 Examples: Return Value Function Call decimalto.fixed point ('-12.125') '-1100.00100000000000000000000' decimal.to.fixed point (' 7.4') decimal-to-fixed-point(,-0.00625, )--0.00000001100110011001|00, decimal.to.fixed point ('-0.0') 111.01100110011001100110011 r-0.00000000000000000000000' Remember: CodeLoad has additional tests for you to try! Upload your code there and see how your code matches up against harder tests. Part II: Binary Fixed-point Format to Floating-point Format (20 points) Write a function fixed.point.to.floating.point () that takes only one argument, a string called value that contains a binary fixed-point number with exactly 23 digits to the right of the radix point. The function con

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Repairing And Querying Databases Under Aggregate Constraints

Authors: Sergio Flesca ,Filippo Furfaro ,Francesco Parisi

2011th Edition

146141640X, 978-1461416401

More Books

Students also viewed these Databases questions