Re: [R] large integers in R

2010-01-28 Thread Benilton Carvalho
Hi Duncan,

On Tue, Jan 26, 2010 at 9:09 PM, Duncan Murdoch murd...@stats.uwo.ca wrote:
 On 26/01/2010 3:25 PM, Blanford, Glenn wrote:

 Has there been any update on R's handling large integers greater than 10^9
 (between 10^9 and 4x10^9) ?

 as.integer() in R 2.9.2 lists this as a restriction but doesnt list the
 actual limit or cause, nor if anyone was looking at fixing it.

 Integers in R are 4 byte signed integers, so the upper limit is 2^31-1.
  That's not likely to change soon.

But in the hypothetical scenario that this was to change soon and we
were to have 64bit integer type (say, when under a 64 bit OS),
wouldn't this allow us to have objects whose length exceeded the
2^31-1 limit?


Benilton Carvalho




 The double type in R can hold exact integer values up to around 2^52. So for
 example calculations like this work fine:

 x - 2^50
 y - x + 1
 y-x
 [1] 1

 Just don't ask R to put those values into a 4 byte integer, they won't fit:

 as.integer(c(x,y))
 [1] NA NA
 Warning message:
 NAs introduced by coercion

 Duncan Murdoch


 Glenn D Blanford, PhD
 mailto:glenn.blanf...@us.army.mil
 Scientific Research Corporation
 gblanf...@scires.commailto:gblanf...@scires.com


[[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] large integers in R

2010-01-28 Thread Duncan Murdoch

On 28/01/2010 5:30 AM, Benilton Carvalho wrote:

Hi Duncan,

On Tue, Jan 26, 2010 at 9:09 PM, Duncan Murdoch murd...@stats.uwo.ca wrote:

On 26/01/2010 3:25 PM, Blanford, Glenn wrote:

Has there been any update on R's handling large integers greater than 10^9
(between 10^9 and 4x10^9) ?

as.integer() in R 2.9.2 lists this as a restriction but doesnt list the
actual limit or cause, nor if anyone was looking at fixing it.

Integers in R are 4 byte signed integers, so the upper limit is 2^31-1.
 That's not likely to change soon.


But in the hypothetical scenario that this was to change soon and we
were to have 64bit integer type (say, when under a 64 bit OS),
wouldn't this allow us to have objects whose length exceeded the
2^31-1 limit?


Those are certainly related problems, but you don't need 64 bit integers 
to have longer vectors.  We could switch to indexing by doubles in R 
(though internally the indexing would probably be done in 64 bit ints).


A problem with exposing 64 bit ints in R is that they break the rule 
that doubles can represent any integer exactly.  If x is an integer, x+1 
is a double, and it would be unfortunate if (x+1) != (x+1L), as will 
happen with values bigger than 2^52.


Duncan Murdoch





Benilton Carvalho





The double type in R can hold exact integer values up to around 2^52. So for
example calculations like this work fine:


x - 2^50
y - x + 1
y-x

[1] 1

Just don't ask R to put those values into a 4 byte integer, they won't fit:


as.integer(c(x,y))

[1] NA NA
Warning message:
NAs introduced by coercion

Duncan Murdoch


Glenn D Blanford, PhD
mailto:glenn.blanf...@us.army.mil
Scientific Research Corporation
gblanf...@scires.commailto:gblanf...@scires.com


   [[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] large integers in R

2010-01-28 Thread Thomas Lumley

On Thu, 28 Jan 2010, Benilton Carvalho wrote:


Hi Duncan,

On Tue, Jan 26, 2010 at 9:09 PM, Duncan Murdoch murd...@stats.uwo.ca wrote:

On 26/01/2010 3:25 PM, Blanford, Glenn wrote:


Has there been any update on R's handling large integers greater than 10^9
(between 10^9 and 4x10^9) ?

as.integer() in R 2.9.2 lists this as a restriction but doesnt list the
actual limit or cause, nor if anyone was looking at fixing it.


Integers in R are 4 byte signed integers, so the upper limit is 2^31-1.
 That's not likely to change soon.


But in the hypothetical scenario that this was to change soon and we
were to have 64bit integer type (say, when under a 64 bit OS),
wouldn't this allow us to have objects whose length exceeded the
2^31-1 limit?



The other possibility is that an additional longer type capable of holding 
vector lengths would be included.  In addition to the issues that Duncan 
mentioned, having the integer type be 64-bit means that it wouldn't match the 
Fortran default INTEGER type or the C int on most platforms, which are 32-bit.  
Calling C code would become more difficult.

 -thomas

Thomas Lumley   Assoc. Professor, Biostatistics
tlum...@u.washington.eduUniversity of Washington, Seattle

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Large integers in R

2010-01-28 Thread Len Vir
Hi!

That is somewhat strange.


§R2^100

[1] 1.267651e+30

§R x - 2^50

§R  y - x + 1

§R  y-x

[1] 1

§Rx

[1] 1.1259e+15

§Rx+1

[1] 1.1259e+15



len





From: Duncan Murdoch [murd...@stats.uwo.ca]
Sent: Tuesday, January 26, 2010 4:09 PM
To: Blanford, Glenn
Cc: r-help@R-project.org
Subject: Re: [R] large integers in R

On 26/01/2010 3:25 PM, Blanford, Glenn wrote:
 Has there been any update on R's handling large integers greater than 10^9
(between 10^9 and 4x10^9) ?

 as.integer() in R 2.9.2 lists this as a restriction but doesnt list the
actual limit or cause, nor if anyone was looking at fixing it.

Integers in R are 4 byte signed integers, so the upper limit is 2^31-1.
 That's not likely to change soon.

The double type in R can hold exact integer values up to around 2^52.
So for example calculations like this work fine:

  x - 2^50
  y - x + 1
  y-x
[1] 1

Just don't ask R to put those values into a 4 byte integer, they won't fit:

  as.integer(c(x,y))
[1] NA NA
Warning message:
NAs introduced by coercion

Duncan Murdoch

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Large integers in R

2010-01-28 Thread Bert Gunter
No it isn't strange. Please read:

?options  digits
?print.default   

and then print the results with more digits.


Bert Gunter
Genentech Nonclinical Biostatistics
 
 
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Len Vir
Sent: Thursday, January 28, 2010 4:17 PM
To: R-help@r-project.org
Subject: Re: [R] Large integers in R

Hi!

That is somewhat strange.


B'R2^100

[1] 1.267651e+30

B'R x - 2^50

B'R  y - x + 1

B'R  y-x

[1] 1

B'Rx

[1] 1.1259e+15

B'Rx+1

[1] 1.1259e+15



len





From: Duncan Murdoch [murd...@stats.uwo.ca]
Sent: Tuesday, January 26, 2010 4:09 PM
To: Blanford, Glenn
Cc: r-help@R-project.org
Subject: Re: [R] large integers in R

On 26/01/2010 3:25 PM, Blanford, Glenn wrote:
 Has there been any update on R's handling large integers greater than 10^9
(between 10^9 and 4x10^9) ?

 as.integer() in R 2.9.2 lists this as a restriction but doesnt list the
actual limit or cause, nor if anyone was looking at fixing it.

Integers in R are 4 byte signed integers, so the upper limit is 2^31-1.
 That's not likely to change soon.

The double type in R can hold exact integer values up to around 2^52.
So for example calculations like this work fine:

  x - 2^50
  y - x + 1
  y-x
[1] 1

Just don't ask R to put those values into a 4 byte integer, they won't fit:

  as.integer(c(x,y))
[1] NA NA
Warning message:
NAs introduced by coercion

Duncan Murdoch

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] large integers in R

2010-01-27 Thread Duncan Murdoch

On 27/01/2010 10:50 AM, Blanford, Glenn wrote:

Duncan, thanks.
To the point, R supports -(2**31-1) to 2**31-1 or -2147483647 to +2147483647
-2147483648 is a valid signed integer but returns NA.
Signed integers are -2147483648 to 2147483647
  


Yes, R uses the -2147483648 encoding to store the integer NA.

Duncan Murdoch

Glenn D Blanford, PhD
NAIL lab, PM NSI, Fort Monmouth, NJ
glenn.blanf...@us.army.mil
Scientific Research Corporation
gblanf...@scires.com

From: Duncan Murdoch [murd...@stats.uwo.ca]
Sent: Tuesday, January 26, 2010 4:09 PM
To: Blanford, Glenn
Cc: r-help@R-project.org
Subject: Re: [R] large integers in R

On 26/01/2010 3:25 PM, Blanford, Glenn wrote:
 Has there been any update on R's handling large integers greater than 10^9 
(between 10^9 and 4x10^9) ?

 as.integer() in R 2.9.2 lists this as a restriction but doesnt list the 
actual limit or cause, nor if anyone was looking at fixing it.

Integers in R are 4 byte signed integers, so the upper limit is 2^31-1.
  That's not likely to change soon.

The double type in R can hold exact integer values up to around 2^52.
So for example calculations like this work fine:

  x - 2^50
  y - x + 1
  y-x
[1] 1

Just don't ask R to put those values into a 4 byte integer, they won't fit:

  as.integer(c(x,y))
[1] NA NA
Warning message:
NAs introduced by coercion

Duncan Murdoch


 Glenn D Blanford, PhD
 mailto:glenn.blanf...@us.army.mil
 Scientific Research Corporation
 gblanf...@scires.commailto:gblanf...@scires.com


   [[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] large integers in R

2010-01-27 Thread Blanford, Glenn
Duncan, thanks.
To the point, R supports -(2**31-1) to 2**31-1 or -2147483647 to +2147483647
-2147483648 is a valid signed integer but returns NA.
Signed integers are -2147483648 to 2147483647

Glenn D Blanford, PhD
NAIL lab, PM NSI, Fort Monmouth, NJ
glenn.blanf...@us.army.mil
Scientific Research Corporation
gblanf...@scires.com

From: Duncan Murdoch [murd...@stats.uwo.ca]
Sent: Tuesday, January 26, 2010 4:09 PM
To: Blanford, Glenn
Cc: r-help@R-project.org
Subject: Re: [R] large integers in R

On 26/01/2010 3:25 PM, Blanford, Glenn wrote:
 Has there been any update on R's handling large integers greater than 10^9 
 (between 10^9 and 4x10^9) ?

 as.integer() in R 2.9.2 lists this as a restriction but doesnt list the 
 actual limit or cause, nor if anyone was looking at fixing it.

Integers in R are 4 byte signed integers, so the upper limit is 2^31-1.
  That's not likely to change soon.

The double type in R can hold exact integer values up to around 2^52.
So for example calculations like this work fine:

  x - 2^50
  y - x + 1
  y-x
[1] 1

Just don't ask R to put those values into a 4 byte integer, they won't fit:

  as.integer(c(x,y))
[1] NA NA
Warning message:
NAs introduced by coercion

Duncan Murdoch


 Glenn D Blanford, PhD
 mailto:glenn.blanf...@us.army.mil
 Scientific Research Corporation
 gblanf...@scires.commailto:gblanf...@scires.com


   [[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] large integers in R

2010-01-26 Thread Duncan Murdoch

On 26/01/2010 3:25 PM, Blanford, Glenn wrote:

Has there been any update on R's handling large integers greater than 10^9 
(between 10^9 and 4x10^9) ?

as.integer() in R 2.9.2 lists this as a restriction but doesnt list the actual 
limit or cause, nor if anyone was looking at fixing it.


Integers in R are 4 byte signed integers, so the upper limit is 2^31-1. 
 That's not likely to change soon.


The double type in R can hold exact integer values up to around 2^52. 
So for example calculations like this work fine:


 x - 2^50
 y - x + 1
 y-x
[1] 1

Just don't ask R to put those values into a 4 byte integer, they won't fit:

 as.integer(c(x,y))
[1] NA NA
Warning message:
NAs introduced by coercion

Duncan Murdoch



Glenn D Blanford, PhD
mailto:glenn.blanf...@us.army.mil
Scientific Research Corporation
gblanf...@scires.commailto:gblanf...@scires.com


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.