Newsgroups: comp.std.c Path: 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:Date: Wed, 6 Sep 89 15:34:07 GMT In article 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