I have 3 values, that goes from -1 to 1 all of them.
How can I easily get the most closest value to 1, no matter if its negative or positive?
Example
local a,b,c = -0.8, 0.6, -0.2
local theCloserOne = math.Trick(a,b,c)
-- This is -0.8
print(theCloserOne)
-- Another compare
local a,b,c = -0.8, 0.9, -0.89
local theCloserOne = math.Trick(a,b,c)
-- This is 0.9
print(theCloserOne)
No matter if its negative or positive I just want the closer number to 1 on comparing 3 values.
Any suggestion?
Thank you for ur help :3
EDIT… Emm Im so silly… maybe I should convert them all into positive and compare… Im gonna check. Anyway, any suggestion?
If I get your question right, then I would suggest you using math.abs(). This function converts numbers to their absolute value, meaning negative numbers will get converted to positives. I think you can do the job easily with positive numbers.
Thank you so much for ur answer!
Yup. I decided to convert all numbers to positive. That solved it. I thougt about that minutes after I made the post. I was trying to learn each one of this math functions. And I got stupidly stuck on that compare… Sorry for the stupid post xD
Could you just mark my or your message as solution so people don’t get confused? If anyone gets to this post to find help, it would be easier to orientate.