cvs.gedasymbols.org/archives/browse.cgi   search  
Mail Archives: djgpp/1998/08/27/19:16:25

From: vcarlos35 AT juno DOT com
To: djgpp AT delorie DOT com
Cc: cata AT intergorj DOT ro
Date: Thu, 27 Aug 1998 15:48:30 EDT
Subject: Re: LARGE numbers
Message-ID: <19980827.154839.5903.0.vcarlos35@juno.com>
References: <000d01bdd194$41ca8bc0$8e70e7c1 AT gonzo>

On Thu, 27 Aug 1998 11:25:30 +0300 "Catalin Carstoiu" <cata AT intergorj DOT ro>
writes:
>>oops...
>>I meant 25834242042 with 11 digits.  I cant figure out how to store it.
:(
>>
>
>you can store it into an array. Let's say on a[0] its the length of 
>the number, and then follows the number in reversed order (for a easier
>implementation of operations (+,-,* etc).
>
>So, for your number, the declaration would be:
>int a[]={11,2,4,0,2,4,2,4,3,8,5,2};

For MPI variables, the type should probably be char to make best use
of space.  Ints are also too implementation dependent, leading to all
sorts of hellish errors when you try to port the thing. Additionally, the
numbers 
should be stored in normal computer format to make full use of each array

item, not in Binary-Coded-Decimal. Many of the optimization techniques 
require bit-operations, like shifts and rotates.

>the operations are simulated exactcly as you do them on paper... like 
>in old school days... (of course there are some optimizations :) )

IMHO, Knuth's _Seminumerical Algorithms_ is the Bible for learning
more about this. For example, you can learn about such topics as 
finding optimal addition chains for doing fast modular exponentiation,
among other things. No reason to reinvent the wheel though; there are
many good math libraries on the Internet (MIRACL is nice, as are 
some crypto sources). Java has good support too, if you're willing to
learn another language just to avoid messing with libraries :)


-Karl

_____________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com
Or call Juno at (800) 654-JUNO [654-5866]

- Raw text -


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