1

Trying to convert hexadecimal strings to numbers usable in R (64-bit), I tried (according to the manual page) as.hexstring. Unfortunately I get 'x' cannot be coerced to class "hexmode" more often than I'd like.

In a quick test I found out that as.hexmode("7fffffff") works, but as.hexmode("80000000") does not. So obviously "cannot be coerced" actually means "signed overflow". I'm surprised that a system running on a 64-bit machine is limited to 31-bit numbers.

What I actually want to numerically deal with are strings like 0x12345678.12345678 (representing 64-bit numbers). Do I really have to digest these in four-digit-chunks and put them into a non-integer numeric variable?

U. Windl
  • 3,480
  • 26
  • 54
  • There's a discussion of the limitation and some ways around it here: http://www.win-vector.com/blog/2015/06/r-in-a-64-bit-world/ – Stephen Henderson Feb 17 '17 at 12:51
  • And there are possible workarounds in this answer too.. http://stackoverflow.com/questions/26302706/how-do-i-convert-64-bit-hexadecimal-strings-in-r?noredirect=1&lq=1 – Stephen Henderson Feb 17 '17 at 12:57
  • I can vaguely remember dealing with long numbers on my 8-bit Z80 computer ;-) – U. Windl Feb 17 '17 at 13:02
  • Is there a specific reason why neither of `Rmpfr` and `bit64` are included in the standard installation? Also manual pages should more clearly point out what the domain of numeric-related functions (e.g. when converting a string to a number) is. Perl on 64-bit platforms can deal with 64-bit integers for many years already. – U. Windl Feb 20 '17 at 08:02
  • I guess because they are a workaround rather than a solution. Example pages in R are very variable in quality, relevance ... but then lots of languages have basically got nothing.. – Stephen Henderson Feb 21 '17 at 10:05

0 Answers0