Mail Archives: djgpp/1994/11/26/08:06:14
Hi Kimberley!
On 25 Nov 94, OKRA AT max DOT tiac DOT net wrote:
> This program:
>
> int main() {
>
> long x = -1441992;
> unsigned y = 4;
>
> printf("%d / %d = %d\n",x,y,x/y);
> }
>
> Spits this out:
>
> -1441992 / 4 = 1073381326
It works fine, if you use a cast:
printf("%d / %d = %d\n",x,y,x/(long)y)
I don't know, if this is a bug or a feature (of ANSI-C).
But it's nice, that gcc does not necessarily need a "%ld" for the long
values.
Bye...
Michael
- Raw text -