home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!ogicse!emory!gatech!concert!sas!mozart.unx.sas.com!walker
- From: walker@twix.unx.sas.com (Doug Walker)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: SAS6.1 users: please read
- Message-ID: <Bz3zxI.2A8@unx.sas.com>
- Date: 11 Dec 92 19:10:30 GMT
- Article-I.D.: unx.Bz3zxI.2A8
- References: <1992Dec3.005753.8826@urbana.mcd.mot.com> <Byov0y.nJ@fc.hp.com>
- Sender: news@unx.sas.com (Noter of Newsworthy Events)
- Organization: SAS Institute Inc.
- Lines: 41
- Originator: walker@twix.unx.sas.com
- Nntp-Posting-Host: twix.unx.sas.com
-
-
- In article <Byov0y.nJ@fc.hp.com>, koren@fc.hp.com (Steve Koren) writes:
- |> It seems to me that doing an integer operation on an unsigned and a
- |> signed integer should always result in a signed integer. Anybody
- |> understand why they picked the opposite? Kinda like doing an operation
- |> on an integer and a double should yield a double. Ie, I'd think you'd
- |> always promote to the most general of the types of the operands,
- |> regardless of their order of appearance in the equation.
-
- But what if the unsigned number contained a value that was bigger than
- the signed number could represent? If you converted the unsigned
- number instead, you'd have an OVERFLOW instead of an UNDERFLOW and
- you'd have some very large negative number involved in the operation.
-
- ANSI chose to consider unsigned types wider than their corresponding
- signed types because they can represent larger numbers. You seem to
- be considering signed types wider than unsigned types, from looking at
- your example with doubles and ints, but your term is "more general".
-
- If you consider signed wider than unsigned, you could end up with even
- more confusing results. Consider the following:
-
- unsigned int x = 0x7fffffff;
-
- if(x+1 > 0x7fffffff)
- {
- printf("Ok\n");
- }
-
- Does the "if" condition come out true or false? In this case, it
- comes out true if the result is "unsigned int" as ANSI states, and
- false if the result is "int" as you are suggesting.
-
- --
- *****
- =*|_o_o|\\=====Doug Walker, Software Distiller====== BBS: (919)460-7430 =
- *|. o.| || 1200/2400/9600 Dual
- | o |// For all you do, this bug's for you!
- ======
- usenet: walker@unx.sas.com bix: djwalker
- Any opinions expressed are mine, not those of SAS Institute, Inc.
-