Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How Would I Find Where a Number Lands?

Asked by
INOOBE_YT 387 Moderation Voter
7 years ago

How would I find where a number lands? For example, I have two number ranges, 0-0.20 and 0.21-0.40. How would I find out if a random number lands in between one of those? If a 0.348 got picked, how would I code it to find the right category?

0
I was thinking of that, but it seems inefficient because I am going to need to make dozens of if statements for this. I'll use it anyway. INOOBE_YT 387 — 7y
0
If the value is always a 0.2 difference you can loop through it with a for loop RubenKan 3615 — 7y

1 answer

Log in to vote
0
Answered by
RubenKan 3615 Moderation Voter Administrator Community Moderator
7 years ago
Edited 7 years ago

You'd use an if statement for that. You simpfuly check if the value is Bigger then NumberA, and smaller then NumberB.

if ChosenValue >= 0 and ChosenValue <= 0.2 then
    --stuff
end

if ChosenValue > 0.2 and ChosenValue <= 0.4 then
    --stuff
end
Ad

Answer this question