An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20120503/e7597c0e/attachment.pl>
Difference between 10 and 10L
4 messages · brwin338, William Dunlap, Brian Ripley +1 more
class(10)
[1] "numeric" > class(10L) [1] "integer" > class(10i) [1] "complex" Why not 10I for integer? Perhaps because "I" and "l" look too similar, perhaps because "i" and "I" sound too similar. The "L" does not mean "long": integers are 4 bytes long. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com
-----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of brwin338 Sent: Thursday, May 03, 2012 4:33 PM To: r-help at r-project.org Subject: [R] Difference between 10 and 10L Good Evening We have been searching through the R documentation manuals without success on this one. What is the purpose or result of the "L" in the following? n=10 and n=10L or c(5,10) versus c(5L,10L) Thanks Joe Thanks Joe [[alternative HTML version deleted]]
______________________________________________ R-help at 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.
On 04/05/2012 00:43, William Dunlap wrote:
> class(10)
[1] "numeric"
> class(10L)
[1] "integer"
> class(10i)
[1] "complex" Why not 10I for integer? Perhaps because "I" and "l" look too similar, perhaps because "i" and "I" sound too similar. The "L" does not mean "long": integers are 4 bytes long.
Actually it does: this notation dates from the C language on 16-bit computers where integers were 16-bits and longs were 32-bit (and R has no 'long' type). The author of this in R never explained why he chose the notation, but it is shorter than as.integer(10), and more efficient as the coercion is done at parse time. (C has a different convention: 10 is integer, 10. is double. Changing to that would have altered existing code, since e.g. 4294967296 is not a valid integer.)
Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com
-----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of brwin338 Sent: Thursday, May 03, 2012 4:33 PM To: r-help at r-project.org Subject: [R] Difference between 10 and 10L Good Evening We have been searching through the R documentation manuals without success on this one. What is the purpose or result of the "L" in the following? n=10 and n=10L or c(5,10) versus c(5L,10L) Thanks Joe Thanks Joe [[alternative HTML version deleted]]
______________________________________________ R-help at 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 at 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.
Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
On Thu, May 03, 2012 at 07:32:46PM -0400, brwin338 wrote:
Good Evening We have been searching through the R documentation manuals without success on this one. What is the purpose or result of the "L" in the following? n=10 and n=10L or c(5,10) versus c(5L,10L)
Hi.
The help page ?"1L" or, equivalently, ?NumericConstants says
An numeric constant immediately followed by ?L? is regarded as an
?integer? number when possible (and with a warning if it contains
a ?"."?).
Try typeof(1) and typeof(1L).
Petr Savicky.