Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

llFrand Question

Cherry Hotaling
Registered User
Join date: 25 Feb 2007
Posts: 86
08-15-2007 09:37
Hello,

I was wondering. The Following will randomly generate a positive number 0.0 to 0.5 for integer random.

integer random = (integer) llFrand (0.5);

How would i make it so that it could produce a random number from -0.5 to 0.5 What would i need to do to make the integer random be a random number that spans from negative numbers to positive? -0.5 to 0.5

Thank you for your time.

-Cherry Hotaling
Shadow Subagja
Registered User
Join date: 29 Apr 2007
Posts: 354
08-15-2007 09:40
Random has to be a float, an integer will be truncated and all you'll get is 0's out of that.

For -0.5 to 0.5 do an llFrand(1.0)-0.5, ie a random number from 0 to 1, then shift it by 0.5 by subracting.
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
08-15-2007 09:41
edit: right, what Shadow said..

"llFrand (1.0) - 0.5" should do it.
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!!
- Go here: http://jira.secondlife.com/browse/SVC-1224
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left
Cherry Hotaling
Registered User
Join date: 25 Feb 2007
Posts: 86
08-16-2007 06:28
Thank you very much.

That seemed to have done it.

-Cherry Hotaling