I’m trying to do math.noise(0.5, 0.5, 0.5) ^ 0.6 but its returning nan
local value = math.noise(0.5, 0.5, 0.5) -- this is -0.25
local value = math.noise(0.5, 0.5, 0.5) ^ 0.6 -- this is nan
local value = -0.25 ^ 0.6 -- this is -0.43527528164806206
how would I get the value -0.43527528164806206 when doing math.noise(0.5, 0.5, 0.5) ^ 0.6?
currently I’m doing
local noise = math.noise(0.5, 0.5, 0.5)
local value = if noise < 0 then -(-noise) ^ 0.6 else noise ^ 0.6
The reason the difference occurs is due to the priority of the math operations, basically when you run math.noise(0.5, 0.5, 0.5)^0.6 what you do is (-0.25)^0.6(the power is applied to the negative number), but when you run -0.25^0.6 directly what you do is 0.25^0.6 and then reverse the sign(so the power operation runs on the positive number). According to what I noticed all negative numbers(like -0.25), when powered to a power less than 1(like 0.6) return nan.
So the solution is what @dthecoolest said, use the positive number only, then add back the sign: