Skip to content

Instantly share code, notes, and snippets.

@qoelet
Last active August 29, 2015 13:56
Show Gist options
  • Save qoelet/8930719 to your computer and use it in GitHub Desktop.
Save qoelet/8930719 to your computer and use it in GitHub Desktop.
# hit a snag time when working with session ids (represented as bigint in a database)
df <- read.csv("myData.csv", header=TRUE) # sid is the column
"
> tail(df, n=1)$sid
[1] 2e+18
"
# WTF moment
"
> 2000000002775713071 == 2000000002775713073
[1] TRUE
"
# Treat as character class
df <- read.csv("myData.csv", header=TRUE, colClasses=c("sid"="character"))
"
> tail(df, n=1)$sid
[1] 2000000002775713071
"
# If we really needed to keep work with it as an integer (not in this case but...)
library(gmp)
mySid = as.bigq(tail(df, n=1)$sid, 19)
"
> mySid = as.bigq(tail(df, n=1)$sid, 19)
> mySid
Big Rational ('bigq') :
[1] 2000000002798018836/19
"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment