🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.atari.st
Article #40868

Re: Bug in TURBO-C V1.0

#40868
From: Eric C. Olson
Date: Wed, 14 Feb 1990 17:37
22 lines
1051 bytes
>Look at this C-code:
>    #define MAX  -32768
>    main()
>    {
>    printf("1: %d\n", MAX);
>    printf("2: %d\n", (int)MAX);
>    }

This is not a bug, its a feature.  MAX is not a number, its an expression.
Thus, the evaluation of MAX is a long int.  The first printf only prints
the high word of the long int MAX.  The second printf properly casts the
long int to an int and prints the correct result.  Try:

	printf("3: %ld\n", MAX);

Eric
ericco@sag4.ssl.berkeley.edu



Eric
ericco@ssl.berkeley.edu
Technical Details
Message-ID: <1990Feb14.173746.28244@agate.berkeley.edu>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!wuarchive!uwm.edu!bionet!agate!stew.ssl.berkeley.edu!ericco
References: <8910270333.AA14741@cscwam.UMD.EDU> <0927891128429423@thelake.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!wuarchive!uwm.edu!bionet!agate!stew.ssl.berkeley.edu!ericco
From: ericco@stew.ssl.berkeley.edu (Eric C. Olson)
Newsgroups: comp.sys.atari.st
Subject: Re: Bug in TURBO-C V1.0
Summary: not really
Message-ID: <1990Feb14.173746.28244@agate.berkeley.edu>
Date: 14 Feb 90 17:37:46 GMT
References: <8910270333.AA14741@cscwam.UMD.EDU> <0927891128429423@thelake.UUCP>
Sender: usenet@agate.berkeley.edu (USENET Administrator;;;;ZU44)
Organization: University of California, Berkeley
Lines: 22