[MarkLogic Dev General] RE: General Digest, Vol 38, Issue 10

Jason Hunter jhunter at marklogic.com
Tue Aug 14 13:32:54 PDT 2007


Gary Vidal wrote:
> I tested the xdmp:random() function over 10000 iterations and all 
> results returned random number of 16 bits. Perhaps pure luck?

It's counterintuitive but if you generate random numbers they're more 
likely to be long than short when printed.  That's because fundamentally 
in a given 0 to n range there are vastly more long-when-printed integer 
values than short-when-printed values (only have 10 single digits, 90 
double digits, etc).

In fact, with 64-bit numbers then you'll find half your results will 
have a full 64 bits when printed as raw binary.  Those are the ones for 
which the first (high) bit is 1.  One quarter will print as 63-bits 
(leading 01 with a non-printed 0).  Etc.

-jh-


More information about the General mailing list