delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/08/09/07:45:30

From: "Lawrence Rust" <lvr AT NOsoftSPsystemAM DOT co DOT uk>
Newsgroups: comp.os.msdos.djgpp
References: <Ysdc7.12907$da2 DOT 54030 AT news11-gui DOT server DOT ntli DOT net> <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: <fjsc7.875$zs.4927@news11-gui.server.ntli.net>
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" <toepferei DOT dietrich AT t-online DOT de> wrote in message
news:9krscn$miu$04$1 AT news DOT t-online DOT com...
> Message by Lawrence Rust <lvr AT NOsoftSPsystemAM DOT co DOT uk> 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


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019