Value comparing not working

So, I was making a ratio system and tried to compare the values. This unfortunately didn’t work and did the opposite. Here’s the code(not the full code):

if integer1.Value > integer2.Value then

	table.insert(results, integer1.Value/integer2.Value)
else
	table.insert(results, integer2.Value/integer1.Value)
end

It instead divides integer1 by integer2. I tried this but it had the same results:

if integer1.Value < integer2.Value then

	table.insert(results, integer1.Value/integer2.Value)
else
	table.insert(results, integer2.Value/integer1.Value)
end

I know this because I made it print the results. Here were the results:

0.44444444444444

Integer1’s value is 4 and Integer2’s value is 9. 9 divided by 4 is 2.25 not 0.44444444444444. I even checked and the calculator had the same answer:

image

I really need help on this.

Can we see the rest of the code? Which numbers are input, the function call, so on so forth?

Try printing the values before the calculation to see if values of integer1 and integer2 are as expected

Yes, the values are the exact same.

Here’s the function call script, by the way my script is a module script:

local Math = require(script.Parent.MathModule)

local value1 = script.Value1

local value2 = script.Value2

local results = {}

Math.Ratio(value1, value2, results)

print(results[1])

Also, you don’t need the full code, that code are the only lines of code that edit or compare the values.

Actually, there’s nothing wrong.

You might wanna call it something else than “Math”, seeing as there is an object called “math” xD

Code is case sensitive though.

I know, but sometimes, your brain ain’t.

My other functions work so no need to change that. Try typing Math.random() with a capital m. Will it work?

local integer1=workspace.int1 -- 4
local integer2=workspace.int2 -- 9
if integer1.Value > integer2.Value then
	
	print("1: "..integer1.Value/integer2.Value)
	
else
	print("2: "..integer2.Value/integer1.Value)
end

-- Output= 2: 2.25  -  Server - Script:8

That bit of code works as expected.

The problem is I’m making a module so I can’t just instance a value.

I know, I just instanced them for testing.
My point was the code you have provided works as it should so it must be another part of the script causing you issues.

Nope, even this part wasn’t causing me issues:

if integer1.Value * integer1.Value == integer2.Value or integer2.Value * integer2.Value == integer1.Value then
	table.insert(results, 50)
end

I think this part of the code has no problem

Check integer1.Value and integer2.Value what their value is

Looked into it using an online lua compiler, and came up with this:

local i1 = 9
local i2 = 4
local results = {}

table.insert(results, i1 < i2 and (i1 / i2) or (i2 / i1))

print("Integer 1:", i1,
    "\nInteger 2:", i2,
    "\n------------------",
    "\nResults = {\n", table.concat(results, ",\n"), "\n}"
)

My output:
image

When I swapped the integer value (i.e Integer 1 as 4 and Integer 2 as 9):
image

If I understood right, this was the result you were expecting.

EDIT: I misread, but just change the < to > and it will return 2.25
image

Uhmmm… When I restarted my pc the code worked I guess? Here’s the code:

if integer1.Value < integer2.Value then

	table.insert(results, integer2.Value/integer1.Value)
else
	table.insert(results, integer1.Value/integer2.Value)
end
end

That behaviour is very weird, must be a problem with my computer reading the code.