How to tell if a number is within a range

How would I be able to find if a number was within a certain range? (ex if -2 is within -3 and 3)

Thanks,
RGF

could you do

local num = -2
local minNum = -3
local maxNum = 3

if num > minNum and num < maxNum then
    print("e")
end

you could use >= and <= if you want it to print if they’re equal to the minNum and maxNum too

1 Like

you can do one of these:

way 1:

local min = 1
local max = 5
local number = 2 -- number

if num < max and num > min then
    --do something
end

way 2:

local range = NumberRange.new(1, 5)
local num = 2

if num == range then
    --do something
end
3 Likes

The second example wouldn’t work.

local Range = NumberRange.new(1, 5)
if Range.Min < math.pi and math.pi < Range.Max then
	print("Hello world!")
end
1 Like