[R] speed issue in simulating a stochastic process

Rolf Turner r.turner at auckland.ac.nz
Fri Nov 7 01:17:13 CET 2014


<SNIP>

> On Thu, Nov 6, 2014 at 2:05 PM, Matteo Richiardi <matteo.richiardi at gmail.com
>> wrote:

<SNIP>

>> Final question: in your code you have mean(M[t-1L,]): what is the 'L'
>> for? I removed it at apparently the code produces the same output...

<SNIP>

The constant "1L" is stored as an integer; the constant "1" is stored as 
double precision.  This sometimes makes no difference and sometimes 
makes a huge difference (especially in the context of numerical 
comparisons).  If something is supposed to be an integer it is safer to 
use the "L" form.

See ?NumericConstants.

cheers,

Rolf Turner

-- 
Rolf Turner
Technical Editor ANZJS



More information about the R-help mailing list