Large numbers in Pascal 
Author Message
 Large numbers in Pascal

Hi !

I have a question:
How can i use very large numbers (2000 bit) in Pascal ?

Tnx !
-------------------------------------------------------
Christian Becker

-------------------------------------------------------



Mon, 29 Nov 1999 03:00:00 GMT  
 Large numbers in Pascal


Thu, 12 Jun 1997 16:15:42 in comp.lang.pascal.misc, Christian Becker

Quote:

>Hi !

>I have a question:
>How can i use very large numbers (2000 bit) in Pascal ?

>Tnx !
>-------------------------------------------------------
>Christian Becker

>-------------------------------------------------------

Duff SigSep - see sig.

My   http://www.merlyn.demon.co.uk/programs/longmult.pas    may give you
a clue; it handles numbers of many digits, stored in strings.  It's very
old, and I would not hold it out as an example of "style".

However, you should prefer to use "array of byte" to store your numbers,
and build up from byte arithmetic.  Or possibly "array of word".

You will need to build almost all operations up from simpler ones.

As this is the Misc newsgroup, we cannot give any guidance specific to
whatever version of Pascal you have.
--

  Web URL: http://www.merlyn.demon.co.uk/ -- includes FAQqish topics and links.
  Correct 4-line sig separator is as above, a line comprising "-- " (SoRFC1036)
  Before a reply, quote with ">" / "> ", known to good news readers (SoRFC1036)



Mon, 29 Nov 1999 03:00:00 GMT  
 Large numbers in Pascal

Quote:

> I have a question:
> How can i use very large numbers (2000 bit) in Pascal ?

     I'm sure solutions are already in SWAG, but it isn't difficult to
implement an "infinite" precision integer package in Pascal.  One (not
very optimal) way to do this is to express a number as a series of
digits in a linked list (i.e. "123" is the list "1" -> "2" -> "3").  You
need to develop functions or procedures to do arithmetic on these
"numbers", using the rules you learned in elementary school (add the
ones, take the carry, add the tens and the carry, take the carry, add
the hundreds and the carry, etc.).  You are only limited by computer
memory.

     Note that the above is decidedly NOT an efficient implementation.
However, you can easily generalize this idea of a representation as a
list, and do it all in Pascal, without needing assembler.

Bob Schor
Pascal Enthusiast



Mon, 29 Nov 1999 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Largest Number Allowed In TMT Pascal?

2. Largest possible number in TMT Pascal

3. Largest number Pascal can store

4. Need help with large numbers

5. Very large numbers

6. Trunc for large numbers (COMP)

7. Very large numbers

8. Displaying large numbers

9. Finding the largest number with SQL

10. String calculations (very large numbers)

11. base conversion of large numbers

12. base conversion of large numbers

 

 
Powered by phpBB® Forum Software