Smallest (NOT LOWEST) number Random.new() can take that is not 0

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? I want to know what number Random.new() can take that is not 0

  2. What is the issue? I dont have the screenshot right now, but if you put a number too small for the Random.new() it will change the input number into 0 and say something like "can only take number from (very big negative number) to (very big positive number) and no mention of smallest number.

  3. What solutions have you tried so far? Tried asking chatgpt, tested, wrong.

Can you please clarify on what you mean by the number Random.new() can take?

Are you referring to the seed? In which case, it can take only integers, so the smallest non 0 would be 1 (or -1)

1 Like

so there is no math.random(.5) ?

Nope.

If you want to get smaller values than 1 in math.random(), then you would need to do something like this:

local Maximum = 0.5
local Rand = math.random()
local Number = Rand * Maximum

(The smallest value this way is really small. Not 100% sure on what it is precisely but I’ve confirmed that 0.0000000…00001 (100 zeroes followed by a 1) is valid)

1 Like

Apparently there is, i think we are having a miscommunication right now. :sweat_smile:
Screenshot 2025-06-30 214147

That’s the seed, not the random value.

The seeds are always rounded down to the nearest whole number (so 0, 0.1, 0.5, 0.999 would all give a seed of 0, while 1, 1.01, 1.5, 1.999 would be 1, etc.)

If this still isn’t what you are referring to, can you please elaborate further

1 Like

Oh, I see it now, you are right, the seed will be rounded. So the most smallest number that is not 0 that the Random.new() can take is 1.

print("0.5 = "..Random.new(.5):NextInteger(0,1000))
print("0 = " .. Random.new(0):NextInteger(0,1000))
print("1e-20 = " .. Random.new(1e-20):NextInteger(0,1000))

Screenshot 2025-06-30 214929

Thank you for helping me regarding this question.

Rounded down, not just rounded (so 0.9 will go to 0, not 1)!

(If the post is solved, please mark the reply that helped as the solution, to assist others who come across this post later on :slight_smile: )

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.