SOLVED
Random Number Between -1 and 1
Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
naeema
6 - Meteoroid
‎01-14-2019
03:40 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi,
I am wondering how to generate a random number between negative and positive one.
I've found out how to generate a number between 0 and 1. But in terms of a negative number I've had no luck.
Any advice?
Solved! Go to Solution.
Labels:
- Labels:
- Tips and Tricks
3 REPLIES 3
ACE Emeritus
‎01-14-2019
04:02 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Use a formula tool with expression:
RAND()*2-1
Rand makes a random number between 0 and 1. Then you can double and shift.
‎01-14-2019
04:05 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
I have decided to use two random Values, the second random value will decide whether the first random value is positive or negative (first random value is between 0 and 1).
Any better solutions?
martensite
8 - Asteroid
‎07-15-2019
02:20 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi,
If you only want to show these values: -1, 0 and 1. You can use the following formula:
SWITCH(RandInt(2),1,
0,-1,
1,0,
2,1)
