Related articles |
---|
The signs of literals lin@cs.monash.edu.au (Hung-Ta Lin) (1997-12-07) |
Re: The signs of literals dlmoore@ix.netcom.com (David L Moore) (1997-12-10) |
Re: The signs of literals clark@quarry.zk3.dec.com (Chris Clark USG) (1997-12-10) |
Re: The signs of literals hbaker@netcom.com (1997-12-12) |
Re: The signs of literals tim@wagner.Princeton.EDU (1997-12-12) |
Re: The signs of literals mtimmerm@microstar.no-spam.com (Matt Timmermans) (1997-12-12) |
Re: The signs of literals dlmoore@ix.netcom.com (David L Moore) (1997-12-13) |
From: | hbaker@netcom.com (Henry Baker) |
Newsgroups: | comp.compilers |
Date: | 12 Dec 1997 14:45:04 -0500 |
Organization: | nil |
References: | 97-12-053 97-12-060 |
Keywords: | lex |
David L Moore <dlmoore@ix.netcom.com> wrote:
> Second, it would be incorrect to treat a negative number as a positive
> number with a unary minus preceding it because, if your machine is
> two's compliment, you can now not represent the largest negative
> integer (eg -32768 in 16 bit) as a constant.
The solution to this problem is well-known and trivial. You _always_
build up integers using _negative_ arithmetic, as in `n:=10*n-d'.
You then convert to positive at the last moment _unless_ you see a
minus sign.
There was an article about this issue in Sigplan Notices around 1980
or so.
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.