Answered step by step
Verified Expert Solution
Question
1 Approved Answer
A) Conversion from decimal to binary Write a function that converts a decimal number into a binary number, with n digits (configurable) past the decimal
A) Conversion from decimal to binary Write a function that converts a decimal number into a binary number, with n digits (configurable) past the decimal point. For example, if the input number is 1.231 with n=6 should output the binary number "1.001110". Do not use dec2base or dec2bin (or similar) commands of Matlab for the conversion. Hints: - Use the trick seen in class: if x is your input number, compute x2n, round it as an integer (Matlab command: round() ), convert the number in base 2, and then shift the binary point to the left ' n ' times - To convert an integer in base 2, use the procedure seen in class (remainders of successive divisions by 2 ) - Create the output binary number as a string (or chain of characters). You can use the command strcat() to concatenate strings into a bigger string)
Step 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