🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.micro.pc
Article #6116

Re: weird C behavior

#6116
From: jeff
Date: Mon, 31 Mar 1986 21:48
17 lines
1228 bytes
1) "a decimal constant whose value exceeds the largest signed machine
integer is taken to be long", according to K&R.  Thus, BIG is long if ints
are 16 bits.

2) the assignment "i = BIG" will lose accuracy if an int is shorter than
a long.  if accuracy is lost, then after the assignment, BIG is really
not equal to i.

3) in the comparison "i == BIG", the "usual arithmetic conversions"
are done.  if BIG is long, then i will be converted to long.  however,
if accuracy was lost, there is of course no way to regain it.

thus, the "unexpected" results of the original posting would really
be "expected", on a closer reading of K&R.

	jeff dean, cdp!jeff
Technical Details
Message-ID: <8800006@cdp>
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!gamma!epsilon!zeta!sabre!petrus!bellcore!decvax!decwrl!glacier!cdp!jeff
References: <557@utastro.UUCP>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!gamma!epsilon!zeta!sabre!petrus!bellcore!decvax!decwrl!glacier!cdp!jeff
From: jeff@cdp.UUCP
Newsgroups: net.micro.pc
Subject: Re: weird C behavior
Message-ID: <8800006@cdp>
Date: Mon, 31-Mar-86 16:48:00 EST
Article-I.D.: cdp.8800006
Posted: Mon Mar 31 16:48:00 1986
Date-Received: Sat, 5-Apr-86 04:16:35 EST
References: <557@utastro.UUCP>
Lines: 17
Nf-ID: #R:utastro.UUCP:-55700:cdp:8800006:000:655
Nf-From: cdp.UUCP!jeff    Mar 31 13:48:00 1986