Of Standards and Inventions: A Cautionary Tale

00704a-Liber nevin1 at ihlpf.ATT.COM
Fri Apr 8 04:37:02 AEST 1988


In article <10949 at mimsy.UUCP> chris at mimsy.umd.edu (Chris Torek) writes:
|[...]  But lo! what has happened when we combine them all?
|The answer to that lies in the following question:
|
|	On a machine with 32 bit |long|s and two's complement
|	arithmetic, what is the type of -2147483648 in the preprocessor?
|
|Since the preprocessor is required to follow the same rules as the
|compiler, and is possesed of the notion of unsigned, we find that it is
|first to compute 2147483648 and then to negate it, and when it does the
|former it finds that the type is |unsigned long|.  The negation changes
|nothing: /neither the type nor the value/.  As noted earlier, the only
|way to remove the unsigned attribute is to use a cast.  But since the
|preprocessor explicitly disallows casts, there is no way to get
|-2147483648!

What about doing something like

	(-2147483647 - 1)??

(Yes, I will admit it looks kludgy and I don't particularly like it, but
it should work.)

|The moral, if you will, of this story is that even obvious and
|well-behaved inventions may not always work together.

And even the obvious deficiencies due to new inventions have workarounds!
:-) :-)  Seriously though, I do agree that any changes made have to be
thought out very, very carefully.
-- 
 _ __			NEVIN J. LIBER	..!ihnp4!ihlpf!nevin1	(312) 510-6194
' )  )				"The secret compartment of my ring I fill
 /  / _ , __o  ____		 with an Underdog super-energy pill."
/  (_</_\/ <__/ / <_	These are solely MY opinions, not AT&T's, blah blah blah



More information about the Comp.lang.c mailing list