
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Tags:
- rand


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Rand() function is exclusive of 0 and 1.


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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!!!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Angus,
Rand() function excludes 0 & 1.
It will generate a random number between 0 & 1 excluding them.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Indeed. But it should never be equal to 0 or 1..
