delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/10/14/03:36:08

From: Brian Inglis <Brian DOT dot DOT Inglis AT Compuserve DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: GNU Multiprecission library
Date: Sun, 14 Oct 2001 01:20:41 -0600
Organization: Systematic Software
Lines: 30
Message-ID: <tkifstcb27v51o56l29ej0v03ndipotate@4ax.com>
References: <F145eVe0F7HcCPG6hi40000bb0a AT hotmail DOT com> <000101c15258$c34715e0$2645ce84 AT ECETSP>
NNTP-Posting-Host: h-207-148-143-213.dial.cadvision.com
Mime-Version: 1.0
X-Trace: news3.cadvision.com 1003044041 23599 207.148.143.213 (14 Oct 2001 07:20:41 GMT)
X-Complaints-To: news AT cadvision DOT com
NNTP-Posting-Date: Sun, 14 Oct 2001 07:20:41 +0000 (UTC)
X-Newsreader: Forte Agent 1.8/32.548
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

On Thu, 11 Oct 2001 08:35:03 -0400, "Patrick Mitran"
<pmitran AT tsp DOT ece DOT mcgill DOT ca> wrote:

>> could you please suggest a name for a library whose code is not very long,
>> and that's all in C (again, not necessarily efficient!) we especially need
>> the division, and modulo operators...
>
>Why not just make the computer do long division (like you do it by hand) in
>binary?
>Its pretty easy since the divisor only ever fits in what you're dividing
>either 0 or 1
>times (compared to 0 to 9 times in decimal) and the algorithm only requires
>right shifts and substractions. As a bonus, you get the remainder (modulus)
>as well at the same time.

For arbitrary precision, you can probably implement byte size
(base 256) polynomial arithmetic fairly easily, as the products
fit easily in any int. Use an extra byte for the sign to keep
things easier. Don't have any refs, try a google search on
arbitrary precision arithmetic or look at the source for dc(1).
Did it in Basic functions using strings years ago and it's not
hard to do. It's easier to do with byte sizes than bits (too low
level) or half words (worrying about overflow). 

Thanks. Take care, Brian Inglis 	Calgary, Alberta, Canada
-- 
Brian DOT Inglis AT CSi DOT com 	(Brian dot Inglis at SystematicSw dot ab dot ca)
    fake address		use address above to reply
tosspam AT aol DOT com abuse AT aol DOT com abuse AT yahoo DOT com abuse AT hotmail DOT com abuse AT msn DOT com abuse AT sprint DOT com abuse AT earthlink DOT com abuse AT cadvision DOT com abuse AT ibsystems DOT com uce AT ftc DOT gov
						spam traps

- Raw text -


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