64-bits unsigned integers

193 views
Skip to first unread message

Alexandre Beaulne

unread,
Nov 18, 2014, 6:51:33 PM11/18/14
to personal...@googlegroups.com
Income tax season is coming quick and I reached for my favorite number crunching tool to add everything up, however I ran into a problem:

q)
q)income: 9223372036854775806
q)income
9223372036854775806
q)
q)income: 9223372036854775808
'9223372036854775808
q)income
9223372036854775806
q)


Looks like the biggest integer type in q is 64-bits *signed*, what if I have to interface with systems with 64-bits unsigned integers?

For example, I have CSV files to upload to KDB. In said files one column is Exchange Order IDs, which come in as 64-bits unsigned integers. I don't want to use symbols as to not bombard the symbol table. Strings are inconvenient because comparing them is slow. Casting/converting said Order IDs to 64-bits signed integers prior to uploading to KDB would work but then I need to write a script to pre-process the CSVs and the number will be different to what's in the rest of our systems. Am I missing an easier way to do this?

Thanks,
Alex 

Charles Skelton

unread,
Nov 19, 2014, 5:15:38 AM11/19/14
to personal...@googlegroups.com
for ids, you could use guids

q)"G"$"-"sv 0 8 12 16 20 cut{((32-count[x])#"0"),x}"9223372036854775808"
00000000-0000-0922-3372-036854775808

--
You received this message because you are subscribed to the Google Groups "Kdb+ Personal Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to personal-kdbpl...@googlegroups.com.
To post to this group, send email to personal...@googlegroups.com.
Visit this group at http://groups.google.com/group/personal-kdbplus.
For more options, visit https://groups.google.com/d/optout.

Charles Skelton

unread,
Nov 20, 2014, 8:56:49 AM11/20/14
to personal...@googlegroups.com
another approach
q)b:0x0 sv{((16-count[x])#0x0),x}value"0x","9223372036854775808";b
00000000-0000-0922-3372-036854775808
q)0x0 vs b
0x00000000000009223372036854775808
Reply all
Reply to author
Forward
0 new messages