Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Pytharm 3 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
Pytharm 3
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 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 bin ( ) : https://docs.python.org/3/library/functions.html#bin . 1nt () : 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') decimal-to-fixed-point ( , 7 . 4 , ) decimal.to.fixed.point ('-0.00625') decimal.to.fixed.point ('-0.0') Return Value r-1100.00100000000000000000000 111.01100110011001100110011 -0.00000001100110011001100 '-0.00000000000000000000000Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started