cancel
Showing results for 
Search instead for 
Did you mean: 

Big Integers (larger than long)

sandy_bradley
New Contributor
Anyone know how to handle numbers larger than long in kdb+?

I need to handle numbers with 20+ digits in kdb+. It seems there is no inbuilt data types for this, other than to store the number as a string or hex.

Does anyone know any KDB+ libraries to do hex math i.e. addition, multiplication on hex / binary numbers?

Alternatively, any C libraries to use?

Best,

Alexander
4 REPLIES 4

dotsch
New Contributor
Hi Alexander,

I think __int128 is available in GCC as an extension. I would store those 16byte ints as guids on the kdb side and develop the necessary functions in C.
This is interesting, I might come back to you with some prototype code today/tomorrow.

Regards,
Andras

Thanks Andras,

I found a couple of C libraries that could be modified to integrate K structs:

https://github.com/SzigetiJ/biguint





To anyone looking for Big Integer arithmetic in future, I made a C library to integrate into kdb at:

https://github.com/manifoldfinance/qBigInt



Another option, GCC's __int128 extension as guid: