To any kind soul,
I have a very wierd problem when handling long long ints. Consider the following code.
[cpp]#include <stdio.h>
int main() {
long long int a,b;
scanf("%d%d",&a,&b);
if (a>b)
printf("%d",a-b);
else
printf("%d",b-a);
return 0;
}[/cpp]
Now suppose I input: 2147483648 0
The output is: -2147483648
??!!!!!! The output's supposed to be positive! There is really something very wrong with comparing long long ints.
Pls help me.
Something's terribly wrong with long long ints
Moderator: Board moderators
-
- New poster
- Posts: 14
- Joined: Tue Nov 12, 2002 6:04 pm
- Location: Bulgaria