Skip to content
Back to formatted view

Raw Message

Message-ID: <971536df05041705313c317755@mail.gmail.com>
Date: 2005-04-17T14:31:23Z
From: Gabor Grothendieck
Subject: RFC: hexadecimal constants and decimal points
In-Reply-To: <Pine.LNX.4.61.0504171136210.13254@gannet.stats>

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.