
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 solution
Chapter 2 Solutions
Computer Systems: A Programmer's Perspective (3rd Edition)
- Solve this please and fastarrow_forwardPlease original work Background information: Imagine you are a consultant for a fictional company, FutureTech Innovations, which specializes in advanced technology products. The company is interested in improving its decision-making processes by leveraging Business Analytics (BA) and Management Support Systems (MSS). Talk about how Online Analytical Processing (OLAP) could be used to analyze data from multiple perspectives at FutureTech. What dimensions (e.g., time, product, region) would be important, and how would OLAP enhance decision-making? Talk about the role of data visualization in helping FutureTech understand business performance. What types of visualizations (e.g., dashboards, charts) would be useful, and how would they assist in interpreting data? Please cite in text references and add weblinksarrow_forwardDesign a synchronous Up/Down counter to produce the following sequence (4 9 2,0,7,6,3,1,5) using T flip-flop. The counter should count up when Up/Down =1, and down when Up/Down = 0.arrow_forward
- An active-HIGH pulse (HIGH level when asse rted, LOW level when not) is required on an i nverter input.(a) Draw the appropriate logic symbol, using t he distinctive shape and the negation indicat or, for the inverter in this application.(b) Describe the output when a positive-goin g pulse is applied to the input of an inverter.arrow_forwardConvert this question to Subroutines ORG 100 LDA A1 STA T1 LDA B1 STA T2 LDA T1 I STA A1 I ISZ B1 ISZ A1 ISZ ENC BUN L2 //COMPUTER HLT L1, INC A1, HEX 5000 STA T2 1 B1, HEX 6000 ISZ T1 T1, HEX O ISZ T2 T2, HEX 0 ISZ DCD DCD, DEC -8 BUN L1 // DPNQVUFS ENC, DEC -8 LDA B1 I DEC, HEX FF L2, ADD DEC ENDarrow_forwardConvert this question to Subroutines > F = [(A. B) + (A'. B')]” = [(A. B)'. (A'. B')']' ORG 100 LDA A // Load A operand to AC HLT // END Program AND B CMA STA T1 LDA A CMA STA T2 LDA B CMA AND T2 CMA // Store AC result in T1 // Load A operand to AC // Complement result in AC // Store AC [A'] result in T2 // Load B operand to AC // Complement result in AC // AND B' with T2[A'] operand // Complement result in AC AND T1 // AND [(A'.B')'] with T1[(A.B)'] CMA // Complement result in AC STA F // Store AC result in F // AND A operand with B operand B, HEX 01 // Complement result in AC A, HEX 01 T1, HEX O T2, HEX 0 F, HEX 0 ENDarrow_forward
- Convert this question to Subroutines L1, L2, ORG 100 SKI BUN L1 INP OUT STA CTR CLA // Check input operation ready // Loop back to L1 location // Enter counter (-10) to AC // display counter operand // Store counter in CTR // Clear AC STA LOCI // Clear content of location LOC ISZ LOC ISZ CTR BUN L2 // Go to next Address // Check loop duration // Loop back to L2 location // End program HLT CTR, HEX 0 LOC, HEX 0150 ENDarrow_forwardDesign the following Digital circuit in Verilog. IN1 IN2 MUX A Hint: a typical Demultiplexer is defined by a truth table like the following B DEMUX 1t04 demux_1t04 Sel W X Y Z "00" A 000 "01" 0 A 00 Sel sel demux_sel[1:0] "11" "10" 0 0 AO 000Aarrow_forwardhow do I do this in quartus with picture examples pleasearrow_forward
- I need help with this problem and an step by step explanation of the solution from the image described below. (Introduction to Signals and Systems)arrow_forwardx³dx+y³dy=0arrow_forwardI need help with this problem and an step by step explanation of the solution from the image described below. (Introduction to Signals and Systems)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





