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

can you put a + in front of negavite number to make it positive?

Asked by 3 years ago

Nothing more to say. Help needed!

0
i mean like +negativevalue = 1 where negativevalue = -1 R_LabradorRetriever 198 — 3y
0
is it possible? R_LabradorRetriever 198 — 3y

2 answers

Log in to vote
1
Answered by 3 years ago

Yes, yes you can. But instead of +, you use -. Negative negative = positive.

local negativeNumber = -5
print(negativeNumber) -- console: -5
print(-negativeNumber) -- console: 5
1
additionally you can use math.abs if you are only expecting positive values. Feedekaiser 25 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

A better way to answer this is math.abs. The function always returns a positive number, regardless of wether the input is positive or negative. If you know basic math, this is just an absolute value function.

Answer this question