Explanation of Solution
Function definition for “float_i2f()” function:
The implementation for “float_i2f()”function is given below:
//Header file
#include <stdio.h>
#include <assert.h>
#include <limits.h>
//Declare the float_bits in unsigned data type
typedef unsigned float_bits;
//Function declaration for float_i2f function
float_bits float_i2f(int i);
//Function definition for compute the bit length
int findBitsLength(int i)
{
//Check bit length
if ((i & INT_MIN) != 0)
{
//Returns value "32"
return 32;
}
//Assign the unsigned number
unsigned unum = (unsigned)i;
//Initializes the length is "0"
int len = 0;
//Check the length
while (unum >= (1<<len))
{
len++;
}
//Returns the length
return len;
}
//Function definition to generate mask
unsigned findBitsMask(int bl)
{
//Returns the bits mask
return (unsigned) -1 >> (32-bl);
}
//Fnction definition for compute (float)i
float_bits float_i2f(int i)
{
//Declare variable
unsigned signBit, exponentBit, fractionBit, remainingBit, exp_signBit,rp;
//declare variable bits and float bits
unsigned b, fb;
//Assign bias value
unsigned biasValue = 0x7F;
//If "i" is "0", then
if (i == 0)
{
//Assign all bits to "0"
signBit = 0;
exponentBit = 0;
fractionBit = 0;
//Returns the value
return signBit << 31 | exponentBit << 23 | fractionBit;
}
//If "i" is "INT_MIN", then
if (i == INT_MIN)
{
//Assign given value to each bit
signBit = 1;
exponentBit = biasValue + 31;
fractionBit = 0;
//Returns the value
return signBit << 31 | exponentBit << 23 | fractionBit;
}
//Assign sign bit is "0"
signBit = 0;
/* For two's complement */
/* If "i" is less than "0", then */
if (i < 0)
{
//Assign sign bit to "1"
signBit = 1;
//Assign "i" to "i - i"
i = -i;
}
/* Compute bits length by calling function "findBitsLength" */
b = findBitsLength(i);
//Compute float bits
fb = b - 1;
//Compute exponent value
exponentBit = biasValue + fb;
//Compute remaining bit value
remainingBit = i & findBitsMask(fb);
//If "fb" is less than "23", then
if (fb <= 23)
{
//Assign fraction bit and except bit value
fractionBit = remainingBit << (23 - fb);
exp_signBit = exponentBit << 23 | fractionBit;
}
//Otherwise
else
{
//Compute offset value
int offsetValue = fb - 23;
//To find round middle value
int rm = 1 << (offsetValue - 1);
//For round part
rp = remainingBit & findBitsMask(offsetValue);
//Assign fraction bit and except bit value
fractionBit = remainingBit >> offsetValue;
exp_signBit = exponentBit << 23 | fractionBit;
/*Check if it is round to even */
if (rp < rm)
{
}
//If round to odd, then
else if (rp > rm)
{
...
Want to see the full answer?
Check out a sample textbook solutionChapter 2 Solutions
Computer Systems: A Programmer's Perspective Plus Mastering Engineering With Pearson Etext -- Access Card Package (3rd Edition)
- On a multiple-choice exam, there are 4 possible answers for each of the 6 questions. If a student answers the questions by random guesses, (a) What is the probability that he would get exactly 3 correct answers? (b) What is the probability that he would get at least 1 correct answer? (c) If this problem is solved using a binomial random variable, what would the binomial parameters be?arrow_forwardWhat is the difference between diode clipping and clamping circuits?arrow_forward4. Design a Positive Clamper circuit to obtain the given output waveform. Plot the corresponding input signal. Assume all diodes are ideal. (You do not need to specify the C or R values). V out 5 50 0 -11 |arrow_forward
- 3. Plot the input and output waveforms for the given circuit. What is the difference between the given circuit and double Zener clipping circuits? Assume all diodes are ideal. R=100 Q V=8sin(2000*pi*t) D2 D1 R₂=10k Q V out V=2V de1 dc2 V₁ =5Varrow_forward2. Plot the expected output voltage waveforms for the given circuits and specify the type of the circuit according to your result (positive/negative clipper). Assume all diodes are ideal. (a) V in R (b) DI w in de V out V 0 R out -V 0 out in out dearrow_forwardI need help with this problem and an explanation of the solution for the image described below. (Introduction to Signals and Systems)arrow_forward
- I need help with this problem and an explanation of the solution for the image described below. (Introduction to Signals and Systems)arrow_forwardI need help with this problem and an explanation of the solution for the image described below. (Introduction to Signals and Systems)arrow_forwardI need help with this problem and an explanation of the solution for the image described below. (Introduction to Signals and Systems)arrow_forward
- I need help with this problem and an explanation of the solution for the image described below. (Introduction to Signals and Systems)arrow_forward- | العنوان I need a detailed drawing with explanation so A 4 شكا +x-pu +965 Taylor Series Approximation Example- H.W More terms used implies better approximation f(x)+ f(x) Zero order First order 1.0 0.5 x-0 Second order True f(x) f(x) • flx;+ 1) = f(x) + fƒ '\x;}h √(x,+ 1) = f(x) + f (x)h + "(x) 2 f(x1) X+1-1 f(x) 0.1x 0.15x³-0.5x²-0.25x+1.2 Taylor Series Approximation H.w: Smaller step size implies smaller error Errors 100+ F(x) Zero order First order Second order 0.5 Reduced step size 0 x, 0 f(x+1)f(x,) + ƒ\x,}h 51 f(x + 1) − f(x) + (x)+2 ((x1) +1-1 Using Taylor Series Expansion estimate f(1.35) with x0 =0.75 with 5 iterations (or & s= 5%) for f(x) 0.1x 0.15x³-0.5x2- 0.25x+1.2 マ 52arrow_forwardHome Work Use Taylor's series expansion to Compute the true and approximate percent relative errors & and εa for x = π/6, use 6 iterations for the series. sin(x) == x-arrow_forward
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY