I am taking in a 8 digit hexadecimal number as an IEEE 754 bit floating point number
and i want to print information about that number( signbit, expbits, fractbits, normalized,
denormalized, infinity, zero, NAN) floating point should be a single.
I read up on bit shifting, and i think this is how i am suppose to do it?. however, i am not 100% sure. I understand that the sign bit is found in the left most position of the number. which indicates positive or negative. How much do i shift it to find each? do i just keep shifting it to find each one? Can someone explain how i am to find each one?
would i shift by 1 to find the signbit?
would i shift by 8 to get the exponent?
would i shift by 23 to get the frac?
if so how do i test it after i shift?
this is what i have so far
My input would beCode:#include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { int SwapTest[2] = { 1, 0 }; int HexNumber; printf("Hex IEEE - 754\n"); if( *(short *) SwapTest == 1 ) { //little endian printf("\nbyte order: little-endian\n"); } else { printf("byte order: big-endian\n"); } printf("\n>"); scanf("%x", &HexNumber); printf("\n%#x",HexNumber); return 0; }
40000000
and i get
0x40000000
which is what i want..



LinkBack URL
About LinkBacks



