Code covered by the BSD License  

Highlights from
Variable Precision Integer Arithmetic

Variable Precision Integer Arithmetic



19 Jan 2009 (Updated )

Arithmetic with integers of fully arbitrary size. Arrays and vectors of vpi numbers are supported.

Editor's Notes:

This file was selected as MATLAB Central Pick of the Week

function primeslist = getprimeslist
% loads the primeslist file, and decompresses it, returning the list of primes up to 2^26
% usage: primeslist = getprimeslist
% see also: createprimeslist, primes
% Author: John D'Errico
% e-mail:
% Release: 1.0
% Release date: 7/22/09

% load the compressed form
load _primeslist_

% these are uint8 numbers, where I simply stored
% difference between consecutive primes as a uint8.
% this works, since the largest such difference was
% never more than 220 up to that point.
% The act of decompressing the list takes no more
% than a double and a cumsum.
primeslist = cumsum([2,double(primeslist)]);

Contact us