Question: Please answer it by using the python program Please follow this form thank you. # Part I def decimal_to_fixed_point(value): # Part II def fixed_point_to_floating_point(value): if

Please answer it by using the python program  Please answer it by using the python program Please follow this
form thank you. # Part I def decimal_to_fixed_point(value): # Part II def
Please follow this form thank you.

# Part I

def decimal_to_fixed_point(value):

# Part II

def fixed_point_to_floating_point(value):

if __name__ == '__main__':

# Testing Part I

value = '-12.125'

print('Testing decimal_to_fixed_point() for value = ' + value + ': ' + str(decimal_to_fixed_point(value)))

value = '7.4'

print('Testing decimal_to_fixed_point() for value = ' + value + ': ' + str(decimal_to_fixed_point(value)))

value = '-0.00625'

print('Testing decimal_to_fixed_point() for value = ' + value + ': ' + str(decimal_to_fixed_point(value)))

value = '-0.0'

print('Testing decimal_to_fixed_point() for value = ' + value + ': ' + str(decimal_to_fixed_point(value)))

print()

# Testing Part II

value = '-1100.00100000000000000000000'

print('Testing fixed_point_to_floating_point() for value = ' + value + ': ' + str(

fixed_point_to_floating_point(value)))

value = '-0.00011100001010001111010'

print('Testing fixed_point_to_floating_point() for value = ' + value + ': ' + str(

fixed_point_to_floating_point(value)))

value = '-0.00000000000000000000000'

print('Testing fixed_point_to_floating_point() for value = ' + value + ': ' + str(

fixed_point_to_floating_point(value)))

value = '1111011.01110100111010100100101'

print('Testing fixed_point_to_floating_point() for value = ' + value + ': ' + str(

fixed_point_to_floating_point(value)))

Part I: Convert Decimal Format to Binary Fixed-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 CSE 101-Fall 2017 Lab #10 Page 1 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 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 b in ( ) : https://docs.python.org/3/library/functions.html#bin . Int () : https://docs.python.org/3/library/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 , ') Examples Function Call decimal to.fixed point -12.125') 1100.00100000000000000000000 decimal-to-fixed-point (, 7 . 4 , ) decimal-to-fixed-point(,-0.00625,) | ,-0.00000001100110011001100, decimal.to-fixed-point ('-0.0' ) Return Value 111.01100110011001100110011' ,-0. 00000000000000000000000

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!