Question
==================================================================================================================== Note: the below text is from the other file, I am not sure is useful or not. const uInt SIGN_SHIFT = 31; #define SIGN_MASK
====================================================================================================================
Note: the below text is from the other file, I am not sure is useful or not.
const uInt SIGN_SHIFT = 31;
#define SIGN_MASK (uInt)(0x1
const uInt EXPONENT_SHIFT = 23;
#define EXPONENT_MASK (uInt)(0xFF
const uInt EXPONENT_DENORMALIZED_BIT_PATTERN = 0x00;
const int DENORMALIZE_EXPONENT = -127;
const uInt EXPONENT_BIAS = 0x7F;
const uInt MANTISSA_MASK = 0x007FFFFF;
const uInt MANTISSA_HIDDEN_BIT = 0x00800000;
const uInt MANTISSA_SHIFT = 0;
const uInt NUM_MANTISSA_BITS = 24;
// PURPOSE: To return '1' if 'number' is positive, or '0' otherwise. int isPositive (float number ) { uInt bitPattern = *(uInt*)&number;
if ( (bitPattern & SIGN_MASK) == SIGN_MASK ) return(0);
return(1); }
// PURPOSE: To return the power-of-2 exponent of 'number'. int obtainExponent (float number ) { int bitPattern = *(uInt*)&number;
bitPattern = bitPattern & EXPONENT_MASK; bitPattern = bitPattern >> EXPONENT_SHIFT; return(bitPattern - EXPONENT_BIAS); }
// PURPOSE: To return the mantissa of 'number'. int obtainMantissa (float number ) { int bitPattern = *(uInt*)&number;
bitPattern = bitPattern & MANTISSA_MASK; bitPattern = bitPattern >> MANTISSA_SHIFT;
if (obtainExponent(number) != DENORMALIZE_EXPONENT) bitPattern = bitPattern | MANTISSA_HIDDEN_BIT;
return(bitPattern); }
3. Bit manipulation and Floating point representation (10 points) (10 Points) IEEE single preceision float point notation is: most significant SEEE, EEEE EMMM, MMMM MMMM,MMMM MMMM, MMMM least significant where: o S-sign bit (0 = positive, 1 negative) o EEEE,EEEE are the exponent bits: Bit pattern (EEEE,EEEE) ower of 2 2 0111,1101 0111,1110 2 2 0 1000,0000 1000,0001 2 2 2 2 o MMM, MMMM MMMM,MMMM MMMM,MMMM are the mantissa bits (with the highest 1 bit, the "hidden bit", not stored) Finish this function that reverses the order of these fields. (The bits inside each field are not reversed). Thus the new bit pattern will be: most significant least significant MMMM, MMMM MMMM, MMMM MMMM,MMME EEEE, EEES float reverseFloatFields (float f unsigned int u - *(unsigned int*)&f; unsigned int signII SOME EXPRESSION HERE unsigned int exp unsigned int mant/I SOME EXPRESSION HERE SOME EXPRESSION HERE / SOME EXPRESSION HERE float toReturn*(float*)&u; return (toReturn) 3. Bit manipulation and Floating point representation (10 points) (10 Points) IEEE single preceision float point notation is: most significant SEEE, EEEE EMMM, MMMM MMMM,MMMM MMMM, MMMM least significant where: o S-sign bit (0 = positive, 1 negative) o EEEE,EEEE are the exponent bits: Bit pattern (EEEE,EEEE) ower of 2 2 0111,1101 0111,1110 2 2 0 1000,0000 1000,0001 2 2 2 2 o MMM, MMMM MMMM,MMMM MMMM,MMMM are the mantissa bits (with the highest 1 bit, the "hidden bit", not stored) Finish this function that reverses the order of these fields. (The bits inside each field are not reversed). Thus the new bit pattern will be: most significant least significant MMMM, MMMM MMMM, MMMM MMMM,MMME EEEE, EEES float reverseFloatFields (float f unsigned int u - *(unsigned int*)&f; unsigned int signII SOME EXPRESSION HERE unsigned int exp unsigned int mant/I SOME EXPRESSION HERE SOME EXPRESSION HERE / SOME EXPRESSION HERE float toReturn*(float*)&u; return (toReturn)Step 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