MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: big integer for Range

  • To: mathgroup at smc.vnet.net
  • Subject: [mg61299] Re: big integer for Range
  • From: "Scout" <mathem at tica.org>
  • Date: Fri, 14 Oct 2005 22:22:29 -0400 (EDT)
  • References: <diktip$515$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

"Murray Eisenberg" <murray at math.umass.edu> ha scritto 
news:diktip$515$1 at smc.vnet.net...
> Mathematica 5.2 under Windows XP on a 32-bit machine complains if I ask
> it to form Range[10^9].  The error is Range::range: Range specification
> in Range[10000000000] is not a machine-size integer.
>
> Is there a built-in Mathematica function that tells what the machine's
> maximum machine-size integer is?  (And if not, shouldn't there be?)
>
> -- 
> Murray Eisenberg                     murray at math.umass.edu
> Mathematics & Statistics Dept.
> Lederle Graduate Research Tower      phone 413 549-1020 (H)
> University of Massachusetts                413 545-2859 (W)
> 710 North Pleasant Street            fax   413 545-1801
> Amherst, MA 01003-9305
>

Hi Murray,
that's a very critical question!
First of all, memory is the primary resource which limits the size of 
computations you can do.
The amount of memory is equal to the physical number of bytes of RAM in the 
computer. But there is also a certain amount of "virtual memory", managed by 
the O.S. (or by yourself !).

Now, $MaxMachineInteger gives the maximum integer that is represented 
internally on your computer; typically on an n-bit system is 2^(n-1) - 1.
On 32-bit PC, each integer is represented by 4 bytes (which can differ 
substantially from one system to another!).
To store n integers, that is the case of the Range[n] command (skipping the 
few bytes necessary to the structure) we need the amount of

        f[n_]:=(4*n)/2^20;
MBytes of ram.

        startMem = MemoryInUse[]/(1024*1024);
this gives the number of MBytes of memory currently being used by 
Mathematica.

Well, now keep in mind the dimension of the virtual memory used by Windows 
as you can see in the advanced properties of your system; let's say VM its 
dimension;
Also let's say RAM the dimension of r.a.m. of your system (in MBytes) and
PROGRAMS the dimension of all the processes running on the system at that 
time (obviously in MBytes).

Now, solving the below equation you get the max integer that you can use 
with Range[] :

        Solve[f[n] == VM + RAM - PROGRAMS - startMem , n];

Please, note that this solution is qualitative but useful to extract a 
superior limitation.

Regards,
    ~Scout~ 


  • Prev by Date: Re: Compile nested loops with depending index variables...
  • Next by Date: Re: URL to be the value of ButtonData
  • Previous by thread: Re: big integer for Range
  • Next by thread: Re: Re: big integer for Range