Article View: comp.std.c
Article #525Re: subtraction between unsigned ints
From: Henry Spencer
Date: Wed, 06 Sep 1989 15:34
Date: Wed, 06 Sep 1989 15:34
13 lines
1081 bytes
1081 bytes
In article <KURO.89Sep5111940@shochu.Sun.Com> kuro@shochu.Sun.Com (Teruhiko Kurosaka - Sun Intercon) writes: >Does pANSI defines the datatype of the result of subtraction >between unsigned integers? Would it be also unsigned? Then >what would be the result of subtraction of a number from a >smaller number? ... Unsigned - unsigned gives unsigned. Unsigned arithmetic is done modulo the type size, roughly speaking, so carries and borrows off the top end are ignored. The value of "(unsigned)3 - (unsigned)5" depends on how big the unsigned type is, but on a 16-bit machine it's probably (unsigned)65534. -- V7 /bin/mail source: 554 lines.| Henry Spencer at U of Toronto Zoology 1989 X.400 specs: 2200+ pages. | uunet!attcan!utzoo!henry henry@zoo.toronto.edu
Technical Details
Message-ID:
<1989Sep6.153407.18638@utzoo.uucp>Path:
arc1-ca.pugleaf.net!utzoo!henryReferences:
<KURO.89Sep5111940@shochu.Sun.Com>Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c Path: arc1-ca.pugleaf.net!utzoo!henry From: henry@utzoo.uucp (Henry Spencer) Subject: Re: subtraction between unsigned ints Message-ID: <1989Sep6.153407.18638@utzoo.uucp> Organization: U of Toronto Zoology References: <KURO.89Sep5111940@shochu.Sun.Com> Date: Wed, 6 Sep 89 15:34:07 GMT