V
vikky
hi all,
Out of sheer curosity, I decided to initialize an integer with a number
bigger than INT_MAX, however I still am not able to justify its output.
Here is the program :
#include<stdio.h>
int main(void)
{
int t=0xFFFFFFFFFFFFFFFFDABC;
printf("t is : %x\n",t);
getchar();
return 0;
}
I ran this program using Dev-C++ in Windows on x86( gcc.exe
"C:\Untitled.c" -o "C:\Untitled.exe" -Wall -pg -g3
-I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib" -lgmon -pg -g3)
The output was
t is : ffffdabc
What is happening in here?
And even if I write
int t=0xFFFCFDFAFFFFFFFFDABC;
it is giving the same output. Infact even if i increase any hex digit
at beginning(like int t=0xFFAAAAFFFFFFFFFFFFFFDABC it is giving the
same output.
I guess its some kind of truncation going on .. but then why is it
ignoring MSBs ? I am also guessing this behaviour is compiler dependent
- am i correct?
Out of sheer curosity, I decided to initialize an integer with a number
bigger than INT_MAX, however I still am not able to justify its output.
Here is the program :
#include<stdio.h>
int main(void)
{
int t=0xFFFFFFFFFFFFFFFFDABC;
printf("t is : %x\n",t);
getchar();
return 0;
}
I ran this program using Dev-C++ in Windows on x86( gcc.exe
"C:\Untitled.c" -o "C:\Untitled.exe" -Wall -pg -g3
-I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib" -lgmon -pg -g3)
The output was
t is : ffffdabc
What is happening in here?
And even if I write
int t=0xFFFCFDFAFFFFFFFFDABC;
it is giving the same output. Infact even if i increase any hex digit
at beginning(like int t=0xFFAAAAFFFFFFFFFFFFFFDABC it is giving the
same output.
I guess its some kind of truncation going on .. but then why is it
ignoring MSBs ? I am also guessing this behaviour is compiler dependent
- am i correct?