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?
signbit should be zero
expbits should be 128
fracbits should be 0x00000000 I think...
if so how do i test it after i shift?
this is what i have so far
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
short wordOrder = 0x0100;
int HexNumber;
printf("Hex IEEE - 754\n");
if(wordOrder == 0x0100)
{
printf("\nbyte order: big-endian\n");
}
else
{
printf("byte order: little-endian\n");
}
printf("\n>");
scanf("%x", &HexNumber);
printf("\n%#x",HexNumber);
return 0;
}
my input(scanf) on how i want it..
>40000000
0x40000000
which is what its doing..