Hexadecimal literals in GNU R

March 11, 2013

[This article was first published on R snippets, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Recently I have used hexadecimal numbers in GNU R. The way they are parsed surprised me and is inconsistent with Java. As R Language Definition pdf only briefly mentions hexadecimal numbers here is what I have found.

First I have checked the following code:

# 17

# 17

I seemed that GNU R drops the decimal point. So I have checked notation with exponent being power of 2 (as in Java):

# 1.0625

# 17

Now decimal point is correctly taken into account so I have checked further.

In the notation without exponent part GNU R just discards decimal points as in this example:

# 273
# 273

# 273

However, in notation with exponent last decimal point is taken into consideration and all earlier decimal points are ignored:

# 17.0625
# 17.0625

# 17.0625

In summary – handling of hexadecimal literals in GNU R is nonstandard and at least for me – unexpected.

To leave a comment for the author, please follow the link and comment on their blog: R snippets.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Search R-bloggers


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)