I am currently trying to port an equation to roblox but I need to use negative exponents, but as in just negative numbers, but like the dividing exponent. How do I do that?
Like:
x - the base
y - exponent
x / (x * y)
Is that what you want?
Do you mean something like
5^(-1)
?
If you’d like to use for example ⅓
as the exponent in your equation you can use this method:
2^(1 / 3)
According to the law of exponents, it says that a negative exponents has this formula,
(n1 is base, n2 is exponent)
n1^-n2 = 1/n1^n2
So we could use this law to make a function that works out
function neg_exp(n1,n2)
return (1/n1^n2)
end
Hope this helps!
or you could just use the solution below
heres a F key(idk why) F
Lua supports negative exponents.
print(math.pow(2, -3)) -- 2 to the negative 3, prints 0.125
This goes back to radicals
2^1/3 is equivalent to the cuberoot of 2.
It is the cube root of 2
Since Luau doesn’t have a math.cbrt
function it’s what you need to do to calculate it
Or, we can start a petition for math.cbrt
I totally forgot about this topic lol but apparently I did actually get the exponent thing right, but the equation just didn’t work.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.