Bug 15753 - anomoly in parsing hexadecimal constants ending with "p-<n>L".
Summary: anomoly in parsing hexadecimal constants ending with "p-<n>L".
Status: CLOSED FIXED
Alias: None
Product: R
Classification: Unclassified
Component: Language (show other bugs)
Version: R 3.0.3
Hardware: Other Other
: P5 minor
Assignee: R-core
URL:
Depends on:
Blocks:
 
Reported: 2014-04-15 19:49 UTC by Bill Dunlap
Modified: 2014-05-20 13:33 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bill Dunlap 2014-04-15 19:49:10 UTC
In R-2.15.3 the text
   0x110p-5L
is parsed as the numeric (double precision) value (16^2+16^1)/2^5=8.5, the same as the L-less 0x110p-5.  In R-3.0.3, it is parsed as the numeric value 16^2+16^1=272, while 0x110p-5 is parsed as the expected 8.5.

The R-3.0.3 parser also emits a warning which seems to be truncated:
> str(parse(text="0x110p-5L")[[1]])
 num 272
Warning message:
In parse(text = "0x110p-5L") :
  non-integer value 0x110p- qualified with L; using numeric value
The warning describes what should have happened, not what did.

If the n in "p-<n>L" is small enough that the result is integral, then the parser gives an integer with the correct value:
> str(parse(text="0x110p-4L")[[1]])
 int 17

This change may have been due to fixing bug 15234 (Hexadecimal literals are not parsed correctly).
Comment 1 Martin Maechler 2014-04-28 18:32:36 UTC
This is also in R 3.1.0 and current R-devel (and 3.1.0 patched).

Indeed at least a bug in the warning message ("0x110p-" instead of "0x110p-5" or "...-5L"),
but I'd say it really should return the same as without ending 'L' ...
but then I am not a hex-const-xpert.
Comment 2 Brian Ripley 2014-05-20 13:33:02 UTC
There were two lines in the parser code which were no longer appropriate after the bugfix.