# [Maxima] Integer overflows

Stavros Macrakis macrakis at alum.mit.edu
Wed Jun 6 12:45:40 CDT 2012

```Jorge,

Welcome to Maxima!

Maxima can represent exact, explicit integers essentially to the limit of
memory capacity. It is generally a bad
idea<http://en.wikipedia.org/wiki/Thrashing_(computer_science)>to
manipulate numbers that are larger than RAM, even if your computer can
address more.

An n-bit integer is represented internally with either n/8 and n/4 bytes
(depending on the implementation).  Thus, the number 2^3^4^5 would take
over 10^487 bytes of memory.  You can calculate this in Maxima directly
using bigfloat arithmetic:

log(2b0^3b0^4b0^5b0)/log(2b0^8)

Given that all the computer memory on earth comes to about 10^21
bytes<http://www.smartplanet.com/blog/thinking-tech/what-is-the-worlds-data-storage-capacity/6256>
and
that there are only about 10^80 atoms in the
universe<http://en.wikipedia.org/wiki/Observable_universe#Matter_content>,
it seems unlikely that that number could be expressed *in extenso.
*Practically
speaking
*
*
What exactly are you trying to accomplish?

For example, using bfloat arithmetic, you can easily get (say) the first
1000 decimal digits of 2^3^4^5:

2b0^3b0^4b0^5b0, fpprec:1000

Using modular arithmetic, you can easily get (say) the last 1000 decimal
digits:

modulus: 10^1000
rat(2)^3^4^5

(This comes out negative; you can use modulus(..., 10^1000) to get the
positive version.)

Does any of this help?

-s

On Wed, Jun 6, 2012 at 12:50 PM, Jorge Calvo <Jorge.Calvo at avemaria.edu>wrote:

> Hello:
>
> I just started learning Maxima and am enjoying it quite a bit.  In a
> previous post to this list, it was mentioned that entering
>
> > 2^3^4^5;
>
> gives what appears to be an overflow error.  My question is what is the
> largest integer that Maxima can handle.  Information on the actual
> representation of integers would also be appreciated.
>
> Sincerely,
>
> Jorge
> --
> Dr. Jorge Alberto Calvo
> Associate Professor of Mathematics
> Department of Mathematics and Physics
> Ave Maria University
>
> Phone: (239) 280-1608
> Email: jorge.calvo at avemaria.edu
> Web: http://sites.google.com/site/jorgealbertocalvo
>
>
>
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.math.utexas.edu/pipermail/maxima/attachments/20120606/d01fd157/attachment.html>
```

More information about the Maxima mailing list