Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I need to make a program to take in a binary input from the command line (as seen in the examples given), and output it
I need to make a program to take in a binary input from the command line (as seen in the examples given), and output it as a float value (using IEEE standard). If you could implement it as to work with the template that would be very nice. I am also required to use bit fields for the solution. Also comments in the code would be greatly appreciated. Thanks in advance.
Exercise #2: Build Float Values using Bit-fields and Unions You second taak is to implement a way of building float values by inputting an appropriate bit-pattern representing the number according to the IEEE standard. We have supplied a skeleton program that defines a union type conaiating of s 32-bit quantity that can be interpreted as either an unsigned int, an unsigned int that has been partitioned into three bit-fields, or as a float value. The program reads three bit- strings from the command-line, corresponding to the sign exp frac components of a floating point number, stores these values in the union, then displays the bit-strings from the union or debugging), and finally displays the contents of the union as a float value What you need to do is . devise an appropriate bit-field representation for floats that will allow you to easily access to components . complete the getBits) function, which takes bit-strings from the command-ine and stores them in the appropriate components in a Union32 object complete the shouBits() function, which converts the bit-strings for the three components of a floating point value in a Union32 object into a single C string, formatted as in the examples below Examples of how make a float should eventually work: gcc -Wall -Werror gcc -o maf make_a float.o -c-o make a float.o make a float.c Usage: /maf Sign Exp Frac maf: invalid Exp: 1 bits 18866880 8186686688868e86ea80688 float: 2.508e008000 bits 1 10366880 8108003068eaee0a00a8008 float 2.58e880080 Float: .8036688oe8 not really 8, but very close float: 1.7580688008 corvert three bit stins celready chackod) 3 includeStep 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