Question
problem 1
midterm-1-coding.pdf C:/Users/Cute%20khalsa/Downloads/midterm-1-coding.pdf 2 Problem #1 The first problem is to write the fro
2 Problem #1 The first problem is to write the from.fixed point function, using bit fiddling double from_fixed_point (unsig
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Program

#include<stdio.h>

//function from_fixed_point
double from_fixed_point(unsigned short x)
{
unsigned short a, b;
double c;
//isolated rightmost 4 bits
b = x & 0xf;
//isolated leftmost 12+ bits
a = x >> 4;
//divide by 16 and then add together
c = a + (double)b/16;
//return the double value
return c;
}

//main function
int main(void)
{
unsigned short x = 0x28;

double y = from_fixed_point(x);

printf("%f", y);
}

Output:

2.500000

N.B. Whether you face any problem or need any modification then share with me in the comment section, I'll happy to help you.

Add a comment
Know the answer?
Add Answer to:
problem 1 midterm-1-coding.pdf C:/Users/Cute%20khalsa/Downloads/midterm-1-coding.pdf 2 Problem #1 The first problem is to write the from.fixed point...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 2. Serial shift registers Draw missing connections to implement various shift registers 1. Shift right: All...

    2. Serial shift registers Draw missing connections to implement various shift registers 1. Shift right: All bits of the register move right by one position, and a new bit value from a serial input is stored in the most significant bit (leftmost flip-flop below). Serial input -02 az 02 a Do ao Serial indino 2. Shift left: All bits of the register move left by one position, and a new bit value from a serial input is stored in the...

  • Note: All assembly code should be well commented-similar level of detail to samples. 7. Write ARM...

    Note: All assembly code should be well commented-similar level of detail to samples. 7. Write ARM code that decodes the immediate value in an instruction-takes the last 12 bits and turns it into the value it represents a. Start by loading r1 with the value E3A01CFA (machine code for a move immediate into register) b. Isolate bits 0-7 (the rightmost 8 bits) the 8-bit binary number - into r2 c. Isolate bits 8-11 d. Multiply r3 by 2 to get...

  • Problem 5 (20 points) Consider a floating point number representation that is 16 bit wide. The...

    Problem 5 (20 points) Consider a floating point number representation that is 16 bit wide. The leftmost bit is the sign bit, and the next 5 bits from the left make up an exponent (which has a bias of 15). The remainder 10 bits give the magnitude of the number. This representation assumes a hidden 1. Consider the number -1.3215 x 10-1 How doe its rine and acrac cmpare wit a he same number, this time b) How does its...

  • Write a C program, that would take a negative number as a input from the console,...

    Write a C program, that would take a negative number as a input from the console, and convert it into 2’s complement binary representation. Recall that, there are two steps to that: ● 1’s complement of the positive bitwise representation, which is similar to bit flipping. ○ Find out the appropriate bitwise operator for that, or do it manually. ● Add 1 with the 1’s complement number. ○ Simply add 1 with the number you get in the previous step....

  • Question 5 The shortest IEEE standard for rep- expnt fraction resenting rational numbers is calle...

    PLEASE NOTE: PLEASE ANSWER IN MATHEMATICAL FORM!! THIS IS NOT ESSAY QUESTION. THANKS Question 5 The shortest IEEE standard for rep- expnt fraction resenting rational numbers is called half-precision float- sign (S bit) ing point. It uses a 16-bit word partitioned as in the I diagram at right. (This diagram is taken from the Wiki can be found.) (10 bit) article on the subject, where more details 15 10 As described in lectures, to store a rational number r it...

  • Consider a 9-bit floating-point representation based on the IEEE floating-point format, with one sign bit, four...

    Consider a 9-bit floating-point representation based on the IEEE floating-point format, with one sign bit, four exponent bits (k = 4), and four fraction bits (n = 4). The exponent bias is 24-1-1-7. The table that follows enumerates some of the values for this 9-bit floating-point representation. Fill in the blank table entries using the following directions: e : The value represented by considering the exponent field to be an unsigned integer (as a decimal value) E: The value of...

  • Problem 4 (10 points): 1. Consider the numbers 23.724 and 0.3344770219. Please normalize both 2. ...

    please help Problem 4 (10 points): 1. Consider the numbers 23.724 and 0.3344770219. Please normalize both 2. Calculate their sum by hand. 3. Convert to binary assuming each number is stored in a 16-bit register. Half-precision binary floating-point has: sign bit: lbit, exponent width: 5bits and a bias of 15, and significand 10 bits (16 bits total) 4. Show cach step of their binary addition, assuming you have one guard, one round, and one sticky bit, rounding to the nearest...

  • Problem 9 (8 points): Q1 (4 points): Write down the bit pattern in the fraction of value 1/3 assu...

    Problem 9 (8 points): Q1 (4 points): Write down the bit pattern in the fraction of value 1/3 assuming a floating point format that uses binary numbers in the fraction. Assume there are 24 bits, and you do not need to normalize. Is this representation exact? 02 (4 points): Write down the bit pattern in the fraction of value 1/3 assuming a floating point format that uses Binary Coded Decimal (base 10) numbers in the fraction instead of base 2....

  • I have the problem with the code, when I input 0xef1e4 0x5 3, it doesn't execute...

    I have the problem with the code, when I input 0xef1e4 0x5 3, it doesn't execute anything. I get the code from https://www.chegg.com/homework-help/programming-in-c-4th-edition-chapter-11-problem-6e-solution-9780321776419 but it seems error #include <stdio.h> int intSize(void) { unsigned int n= ~0; int counter = 4; while(n>0) { n=n>>1; counter++; } return counter-1;//account for sign bit } //function to calculate the min number of bits needed to represent a value int numberOfBits(unsigned int x) { int sizeOfInt=intSize(); int counter = 0; unsigned int temp = 1<<(sizeOfInt...

  • (3 pts) Consider an unsigned fixed point decimal (Base10) representation with 8 digits, 5 to the...

    (3 pts) Consider an unsigned fixed point decimal (Base10) representation with 8 digits, 5 to the left of the decimal point and 3 to the right. a.      What is the range of the expressible numbers?    b.      What is the precision?    c.       What is the error?    ______________________________________________________________________________   (3 pts) Convert this unsigned base 2 number, 1001 10112, to each base given below   (Note: the space in the binary string is purely for visual convenience) Show your work. Using...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT