GLBasic forum

Main forum => GLBasic - en => Topic started by: aroldo on 2013-Aug-03

Title: RANDOM Numbers with negative range
Post by: aroldo on 2013-Aug-03
This sounds silly but how can I usee the RND function to generate a random number between -1 and 1? Instead of 0-1?
Title: Re: RANDOM Numbers with negative range
Post by: spicypixel on 2013-Aug-03
RND(2)-1
Title: Re: RANDOM Numbers with negative range
Post by: erico on 2013-Aug-04
Only integers or do you need float point?
Title: Re: RANDOM Numbers with negative range
Post by: aroldo on 2013-Aug-04
Thank you spicypixel and erico,

For float I did this:

Code (glbasic) Select
LOCAL r# = (RND(20)*0.1)-1 // Genereates random numbers from -0.9 to 0.9