Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The function below (in c) accepts an integer (representing a floating point value) and returns and integer (representing a floating point value). The function multiplies

The function below (in c) accepts an integer (representing a floating point value) and returns and integer (representing a floating point value). The function multiplies the floating point by 2 and also handles the NaN cases. The last return statement actually multiplies the floating point by 2. Can you please show me or explain how "uf + (1<<23)" is equal to mutliplying the floating point by 2? Just confused on that part. Thanks!!

unsigned float_twice(unsigned uf) {

//uf = +-0 case.

if(uf==0 || uf == 0x80000000) return uf;

//NaN case.

if(((uf>>23) & 0xff) == 0xff) return uf;

//Tiny value, but non-zero case.

if(((uf>>23) & 0xff) == 0x00) {

return (uf & (1<<31)) | (uf<<1);

}

//Otherwise, Add 1 to exp value.

return uf + (1<<23);

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Transaction Processing

Authors: Philip M. Lewis, Arthur Bernstein, Michael Kifer

1st Edition

0201708728, 978-0201708721

More Books

Students also viewed these Databases questions