Posts: 56
Threads: 16
Joined: Feb 2012
Looking to do some randomisation on my macro. I learned how to do int random numbers but couldnt find a way to do the same thing with double/ float, with 2 decimal points. Any way of doing this?
Thank you
Posts: 12,086
Threads: 142
Joined: Dec 2002
Function RandomNumber creates double from 0 to 1. If need other range, multiply, and optionally add offset.
Macro
Macro166
out
double d1(5) d2(10)
rep 30
,out d1+(RandomNumber*(d2-d1))
Posts: 56
Threads: 16
Joined: Feb 2012
Great! Just need to limit to 2 decimals and all set
Thank you!
Posts: 12,086
Threads: 142
Joined: Dec 2002
Macro
Macro166
out
double d1(5) d2(10)
rep 30
,out Round(d1+(RandomNumber*(d2-d1)) 2)
Posts: 56
Threads: 16
Joined: Feb 2012
Ha ha i was browsing the forum to find the way to round when your answer poped up
I seriocely cant believe how fast you come up with these solutions. Thank's again Gintaras!