Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Folks,
I just ran a script in which rand() appears to have returned a value greater than 1 ! I actually wanted to test empirically if it'd return exactly 0 or 1 (the documentation on it not being crystal clear on this point), and was surprised to get this result.
Basically, I rand a script to call rand() a billion times and pick-out the min & max values, resulting in the following Script Execution Progress dialog box output:
Rands << AUTOGENERATE(1000000000) 1 lines fetched
vMIN=4.6566128774142e-010
vMAX=1.0000000004657
This is in QV Developer 11.00.11414.0 SR2. QVW is attached.
Does anyone else get this?
Angus.
Hi Angus,
I got the same result on my third reload. I think this should be submitted as a bug.
QV Desktop v11.20.12018.0 SR3 x64.
- Ralf
Hi Angus,
I got the same result on my third reload. I think this should be submitted as a bug.
QV Desktop v11.20.12018.0 SR3 x64.
- Ralf
This has now been reported to QlikTech, Bug ID #65575.
Angus.
QlikTech support has come back to be and reported that after an in-depth analysis, yes, rand() can return values >1.0 but is by design"!
"Dear Angus, Regarding this issue, our R&D did an in-depth investigation and came out with a conclusion that this is actually by design. They also summarized the findings into an article, which is attached to this email. Should you need any further assistance please let me know. Or please confirm if we can close this support case."
(See attachment for their article).
I am shocked and absolutely appalled by this response, that they should dismiss this behaviour as being "as designed" when it clearly breaks its contract. What do other people here think about this?
Angus.
I would agree that it's an unsatisfactory answer. The doc, both pdf and help, only state:
"Returns a random number between 0 and 1."
If R&D is stating that it's ok to return something other than 1, then it's a documentation bug. I would ask to escalate the issue, and have it accepted as either a behavior bug or a doc bug. It seems it has to be one or the other.
-Rob
Rounding is not a really good idea. A test showed it creates accumulations of values even on small amount (50k) of records/calls of rand()..
QlikTech have now accepted this as bug #65575, related to how the random seed is generated. "The probability for the issue to occur is consider to be approx. 1 every 2 billion random values, with an
increased probability the closer to 2 billion generated you get."
QlikTech have notified me that this bug is now fixed in 11.2SR5(12235). I'm not in a position to verify this for myself at the moment, though.
Hi Angus,
I cannot reproduce the issue with your app in v11.2 SR5:

- Ralf
Good one - thanks Ralf!