cancel
Showing results for 
Search instead for 
Did you mean: 

C++ convert large decimal to KDB

ekallivrousis
New Contributor II
I need help to find out if there is compatible function in c++ class used to connect to db that would convert the large(24) decimal place to datatype compatible to kdb
6 REPLIES 6

davidcrossey
Moderator Moderator
Moderator

Hi @ekallivrousis,

You could use the Double / Float type as per the C API Reference

Thanks for posting your query on the forums!

Kind regards,

David

Hi David, 
    To elaborate on @ekallivrousis comment, we are trying to use 128-bit floating point data type (instead of 64-bit(8 byte double) ) to support 24 decimal places instead of 16 decimals supported by double. Currently, as per C API Reference KDB+ supports 4byte(float) and 8byte(double).  Is there were way to store 128-bit floating point values ?

You can see an example of mapping a decimal to either a list of bytes or scaling to a double in this interface.

Hello,

If we store data as list of bytes can we preform math operations? Could you please show an example of this?

The goal here is to store decimals up to 18 places without losing precision as its for Ethereum.

Hi ekallivrousis,

 

This thread may be useful to you:

https://community.kx.com/t5/KX-Technology/Big-Integers-larger-than-long/m-p/228

The comments link to c extension libraries which enable math operators on bigInt datatype. You could do similar for any datatype you need to operate on. This is needed as once the data is stored in bytes there are no native math operations .

 

Hey rocuinneagain,

Correct me if im wrong but this is to do math in C correct? I want to do math operations in the KDB database. The c program will be just putting the data into DB