News:

Function Finder  Find all the functions within source code files

Main Menu

GetRandomFloatValue

Started by XpMe_v1.2, October 27, 2005, 03:25:09 PM

Previous topic - Next topic

XpMe_v1.2

This may be useful for someone.
`----------------------------------------------------------------
Text 333,222, Str$( GetRandomFloatValue(0,500 ,0,99) )
Sync
WaitKey
`-----------------will get a float number from 0.0 to 500.99
Function GetRandomFloatValue(Lmin ,Lmax ,Rmin ,Rmax)
EndFunction Val(Str$(RndRange(Lmin,Lmax)) +"."+ Str$(RndRange(Rmin ,Rmax)) )
`----------------------------------------------------------------
...XpMe v1.2

http://tilemusic.com/

XpMe_v1.2

If a Negative is needed then try this one.

Text 233,122, Str$( GetRandomFloatValue( 0 , 500 ,35 ,   99 , -1) )
Text 233,172, Str$( GetRandomFloatValue(70 , 500 , 0 , 4399 ,  0) )
Print ""
Print "" : Print GetRandomFloatValue(0   ,  500 , 0 ,   99 , -1)
Print "" : Print GetRandomFloatValue(0   , 2500 , 0 ,   99 ,  0)
Print "" : Print GetRandomFloatValue(240 ,  800 , 0 , 1659 , -1)
Sync
WaitKey
`----------------- will get a float number from 0.0 to 500.99
`----------------- or lower numbers or higher numbers
`----------------- add a  -1 to the end and get negative random numbers
Function GetRandomFloatValue(Lmin ,Lmax ,Rmin ,Rmax, minus)
Low$="" : If minus = -1 Then Low$ = "-"
EndFunction Val(Low$ + Str$(RndRange(Lmin,Lmax)) +"."+ Str$(RndRange(Rmin ,Rmax)))
`----------------------------------------------------------------
...XpMe v1.2

http://tilemusic.com/

kevin

#2
 To Get a Random float value use the # postfix to select the float version of the RND number generator.


PlayBASIC Code: [Select]
  Print Rnd#(100)
Print RndRange#(100,200)

Sync
Waitkey