From: "Lawrence Rust" Newsgroups: comp.os.msdos.djgpp References: <9krscn$miu$04$1 AT news DOT t-online DOT com> Subject: Re: 128 bit integer Lines: 24 Organization: Software Systems X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 Message-ID: Date: Thu, 9 Aug 2001 10:01:14 +0100 NNTP-Posting-Host: 213.107.106.28 X-Complaints-To: abuse AT ntlworld DOT com X-Trace: news11-gui.server.ntli.net 997347659 213.107.106.28 (Thu, 09 Aug 2001 10:00:59 BST) NNTP-Posting-Date: Thu, 09 Aug 2001 10:00:59 BST To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com "Kai Dietrich" wrote in message news:9krscn$miu$04$1 AT news DOT t-online DOT com... > Message by Lawrence Rust on: 08.08.01 17:07:35 [snip] > is this correct: > sum[0] = a[0] - b[0]; > carry = sum[0] > a[0] ? 1 : 0; > sum[1] = a[1] - b[1] - carry; Yes, that's correct. Note that this technique relies on unsigned integer underflow and overflow being well defined. ANSI C guarantees this. The method cannot be used with signed integers since under/overflow in this case results in undefined behaviour, although in DJGPP it's well defined. Hence you need to implement your own signed type with 2's complement if you wish the code to be portable. -- Lawrence Rust Software Systems www.softsystem.co.uk