Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
gussfish
Creator II
Creator II

Is rand() inclusive or exclusive of 0 and 1?

Hi Folks,

The doco for rand() merely says it returns a number between 0 and 1, which I'd ordinarily take to mean that it would never return 0 or 1 exactly.  But years of experience have taught me to not make such assumptions to quickly!

So, can anyone tell me if 0 and 1 themselves are meant to be possible return values from rand()?

Thanks & regards,

Angus.


6 Replies
AbhijitBansode
Specialist
Specialist

Rand() function is exclusive of 0 and 1.

dmohanty
Partner - Specialist
Partner - Specialist

As per my experience and usage....its EXCLUSIVE of 0 and 1. as correctly mentioned by QlikView. It generates a random number between 0 and 1.

Regards!!!

Not applicable

Hi Angus,

Rand() function excludes 0 & 1.

It will generate a random number between 0 & 1 excluding them.


Not applicable

If 0 or 1 are valid values for you, it will depend on the precision you are working with. I mean if you round or multiply the Rand() value, you can get 0.0001, and depending on your precision this could be treated as 0. The same for 0.9999

gussfish
Creator II
Creator II
Author

By way of rounding-out this discussion, I've discovered rand() presently can return a value >1.  See here in QlikBug for more information:

http://community.qlik.com/message/393605?et=watches.email.thread#393605

Angus.

rbecher
MVP
MVP

Indeed. But it should never be equal to 0 or 1..

Astrato.io Head of R&D