local function GetPercentage(Value, Accuracy, DecimalPoint)
if Accuracy then
return string.format("%." .. DecimalPoint .. "f", Value * 100)
else
return math.floor((Value * 100) + 0.5)
end
end
local TEST_1 = math.random(1000, 9999)
local TEST_2 = math.random(1000, 9999)
print("last_value_TEST1:", TEST_1)
print("last_value_TEST2:", TEST_2)
local Division = TEST_1 / TEST_2
print("last_value_Division:", Division)
print("\n")
function FixNumber(last_Value1, last_Value2)
print("last_Value1 (" .. last_Value1 .. ") - last_Value2 (" .. last_Value2 .. ")")
print("Equals: last_value_Difference")
print("->")
local last_value_Difference = last_Value1 - last_Value2
print("last_Value_Difference:", last_value_Difference)
local last_value_Added = math.random(100, 1000)
local newest_value = last_Value2 + last_value_Difference + last_value_Added
print("newest_value (NEW_last_value_Value2):", newest_value)
local NEW_DIVISION = last_Value1 / newest_value
print("NEW_DIVISION:", NEW_DIVISION)
return NEW_DIVISION
end
if TEST_1 >= TEST_2 then
print("TEST_1, is greater than TEST_2. Fixing...")
print("============================")
local FIX = FixNumber(TEST_1, TEST_2)
print("============================")
print("Whole Percentage: " .. GetPercentage(FIX) .. "%")
print("Accurate Percentage: " .. GetPercentage(FIX, true, 2) .. "%")
print("============================")
print("FIXED")
else
print("Whole Percentage: " .. GetPercentage(Division) .. "%")
print("Accurate Percentage: " .. GetPercentage(Division, true, 2) .. "%")
end
To embed this project on your website, copy the following code and paste it into your website's HTML: