kdb: how does the vs keyword work for 24 60 60 vs 3805

Viewed 69

https://code.kx.com/q/ref/vs/#byte-representation

Based on above, I know that this converts 50 into base 2 representation.

q)2 vs 50
1 1 0 0 1 0

But how do I interpret the 2 results below?

q)24 60 60 vs 3805
1 3 25

q)100 8 3 6 4 vs 100000
73 4 2 4 0
1 Answers

If you took 3805 as a number of seconds then 24 60 60 will split it out into hours minutes seconds

q)24 60 60 vs 3805
1 3 25
q)0D00:00:01*3805
0D01:03:25.000000000

Doing this calculation more explicitly in q may look something like:

q){reverse floor %[;1^ prev l]y mod l:prds reverse x}[24 60 60;3805]
1 3 25
Related