For some reason when running the above code the if statement is executed but it should not be becasue 28 is not less than -32,768. Do anyone know why this is happening, I am not seeing the reason for this at all!! The num variable is being assigned the correct value. Any help will be greatly appreciated.
Decimal separator in C++ is dot (.), not comma (,).
Comma is another operator which evaluates its operands left-to-rigth and returns result of right one
So your if statement actually: if( (num < -23),(768) )
Result of left operand is discarded and right is returned: if( 768 ), Which is always true.
If you wanted to separate not decimal part, but thousands part, do not do that. All numbers should be written without any separators.
When writing numbers, avoid using separators.
Just write your number as "32768" and not as "32,768".
MiiNiPaa did tell you more about it but didn't tell you the right solution anyways, because there are no floating-point numbers around, and 32768 should be (0xFFFF>>1) ?