Random decimal number

Hey there,
is there a way to generate a random decimal number between 0 and 0.03, for example? (Note: I have tried rnd() and System.Random.Number, but these only return values between 0 and 1).
Any help is appreciated,

Random.number will give you a “random” number in the range 0…1. So, if you multiply the result by 0.03, you may get what you’re looking for.

The reason for my being somewhat vague is that I don’t know just how random your numbers need to be. Random enough for a kid’s game, or for cryptographic security?

Var tempInt As Double = System.Random.InRange(0, 3000) / 10000

Var result as double=system.random.inrange (1,100)/100

Not tried it, but sounds reasonable !

Great minds think alike!

… but only one got it right … so congrats to you.

Thanks everyone for the help. In the future, I will definitely remember basic maths!

As long as you’re okay with “kinda random,” then it’s all good.

Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.