# Why '-5<(unsigned)5' is false? [duplicate]

In c programming why I am getting 0 zero for this? Why -5<(unsigned)5 is false?

main(){
printf("%d",-5<(unsigned)5);
getch();
}


## marked as duplicate by Community♦Nov 25 '15 at 19:31

• I think you have a typo in your program, at least if you want to print the result of the comparison. As it stands, your code will take a pointer to char ("%d"), subtract 5 (-5), try to compare the resulting pointer with integer 5, and then pass the result (an integer) to printf as if it were a pointer. On gcc this gives me an warning: passing argument 1 of 'printf' makes pointer from integer without a cast. Bottomline: you want to have a comma between the format string and the next argument. – Giorgio Nov 25 '15 at 19:59
Because it's doing it as an unsigned comparison, which means it's actually checking if UINT_MAX - 4 < 5, which obviously is false.
• @tyt: Yeah, considering that UINT_MAX is over 4 billion, (assuming 32 bits as the default int size for your system,) that's to be expected. – Mason Wheeler Nov 25 '15 at 19:23