Rand with find(?) sometimes returns strange number.
Is this a bug?
KDB+ 3.3 2015.07.09 Copyright (C) 1993-2015 Kx Systems
l32/ 4()core
q)10?rand 10
2 1 2 1 2 3 2 5 4 7
…
q)10?rand 10
6299546977983373652 2157301088332608031 -7209837269872637184 -453213953909620..
It’s what you get when you use ? with 0 on the RHS
q)10?0
-6739119069145492435 4254529079255828354 8099614742952382528 -7528108271820962578 717681689843314..
Not sure if it’s documented anywhere but it’s always had this behaviour.
? also behaves as rand. http://code.kx.com/wiki/Reference/QuestionSymbol#rand
According to wiki: http://code.kx.com/wiki/Reference/rand
r:rand X
If X is an atom 0, it returns a random value of the same type in the range of that type.
If X is a positive number, it returns a random number of the same type in the range [0,X)
Thank you, Tom, RAHUL.
I understand. In this case, rand is unnecessary, 10?10 is enough.