~ Please forgive me -
- I had a previous post called IEEE - 754 - find signbit, exponent, frac, normalized, etc..
However, i had not registered my nic and i cant edit it. ( so the post is basically dead to me) Can someone delete it? My question is unanswered also. So i am posting this with different code.
- i still need lots of help... so please dont treat this post as a duplicate...
I have found sign bit, exponent bit and mantissa..
What do i test to find normalized? if exp == 0?
what do i test for infinity? exp == 0xff and mantiassa == 0? does the sign have anything to do with it?
what do i test to find Zero? exp == 0 and mantissa == 0? does the sign have anything to do with it?
What do i test to find NAN? can someone please explain as simple as you can since i am just a beginner! Do i have to apply any more masks?
- Is there a order in which i am suppose to accomplish what i want?
This is what i have so far.
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
int HexNumber;
printf("IEEE- 754 \n");
int a = 0x12345678;
unsigned char *c = (unsigned char*)(&a);
if (*c == 0x78) {
printf("\nlittle-endian\n");
} else {
printf("\nbig-endian\n");
}
printf("\n>");
scanf("%x", &HexNumber);
printf("\n%#x",HexNumber);
bool negative = !!(HexNumber & 0x80000000);
int exponent = (HexNumber & 0x7f800000) >> 23;
int mantissa = (HexNumber & 0x007FFFFF);
printf("\nsignBit %d,", negative);
printf("expbits %d,", exponent);
printf("fractbits %#x,", mantissa);
return 0;
}
...and this is my output - which is what i want:
IEEE - 754
little-endian
>C0000000
0xc0000000
signBit 1,expbits 128,fractbits 0,