From ggrothendieck at gmail.com  Sun Apr 17 14:31:12 2005
From: ggrothendieck at gmail.com (Gabor Grothendieck)
Date: Sun Apr 17 14:31:23 2005
Subject: [Rd] RFC: hexadecimal constants and decimal points
In-Reply-To: <Pine.LNX.4.61.0504171136210.13254@gannet.stats>
References: <Pine.LNX.4.61.0504171136210.13254@gannet.stats>
Message-ID: <971536df05041705313c317755@mail.gmail.com>

On 4/17/05, Prof Brian Ripley <ripley@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.


[Rd] RFC: hexadecimal constants and decimal points
Gabor Grothendieck