[Rd] RFC: hexadecimal constants and decimal points

Gabor Grothendieck ggrothendieck at gmail.com
Sun Apr 17 14:31:12 CEST 2005


On 4/17/05, Prof Brian Ripley <ripley at stats.ox.ac.uk> wrote:
> These are some points stimulated by reading about C history (and
> related in their implementation).
> 
> 1) On some platforms
> 
> > as.integer("0xA")
> [1] 10
> 
> but not all (not on Solaris nor Windows).  We do not define what is
> allowed, and rely on the OS's implementation of strtod (yes, not strtol).
> It seems that glibc does allow hex: C99 mandates it but C89 seems not to
> allow it.
> 
> I think that was a mistake, and strtol should have been used.  Then C89
> does mandate the handling of hex constants and also octal ones.  So
> changing to strtol would change the meaning of as.integer("011").

In the windows batch language the following (translated to R):
       month <- substr("20050817",5,2)
must be further processed to removed any leading zero.  Mostly
people don't even realize this and just wind up writing erroneous
programs.  Its actually a big nuisance IMHO.



More information about the R-devel mailing list