Large Integers in Tables and Autotranslation

JSON has a problem when integers get larger than 1016 because JavaScript uses floating point for all its numbers. Most languages, including Python, R, and the JVM languages like Groovy can easily handle integers up to 1019, and sometimes larger.

Numbers this large are useful for measuring time in nanoseconds, for example.

BeakerX table and plot widgets have special support 64-bit and arbitrary precision values. Run these cells, then over over the columns to see their types.

64-bit Longs


In [ ]:
def millis = 1234567890L
def nanos = millis * 1000 * 1000L

table = [[time: nanos + 7 * 1, next_time:(nanos + 77) * 1, temp:14.6],
         [time: nanos + 7 * 2, next_time:(nanos + 88) * 2, temp:18.1],
         [time: nanos + 7 * 3, next_time:(nanos + 99) * 3, temp:23.6]]

beakerx.table_with_longs = table
table

BigNums (arbitrary precision)


In [ ]:
def millis = 1987654321g
// the "g" makes this a bignum, with as many bits as needed
def nanos  = millis * 1000 * 1000g

table = [[time: nanos + 7 * 1, next_time:(nanos + 77) * 777, temp:3.351],
         [time: nanos + 7 * 2, next_time:(nanos + 88) * 888, temp:2.355],
         [time: nanos + 7 * 3, next_time:(nanos + 99) * 999, temp:2.728]]

beakerx.table_with_big_integers = table
table

In [ ]: