Style touch ups

This commit is contained in:
Rerumu 2022-06-25 03:52:03 -04:00
parent 0f96d430b6
commit 951ee169a2
2 changed files with 17 additions and 11 deletions

View File

@ -25,7 +25,7 @@ local math_pow = math.pow
local table_freeze = table.freeze
local from_u32, into_u32, from_u64, into_u64
local num_add, num_subtract, num_multiply, num_divide_unsigned, num_negate, num_bit_not
local num_add, num_subtract, num_multiply, num_divide_unsigned, num_negate, num_not
local num_is_negative, num_is_zero, num_is_equal, num_is_less_unsigned, num_is_greater_unsigned
-- TODO: Eventually support Vector3
@ -231,7 +231,7 @@ function Numeric.divide_signed(lhs, rhs)
end
function Numeric.negate(value)
return num_add(num_bit_not(value), K_ONE)
return num_add(num_not(value), K_ONE)
end
function Numeric.bit_and(lhs, rhs)
@ -393,7 +393,7 @@ num_subtract = Numeric.subtract
num_multiply = Numeric.multiply
num_divide_unsigned = Numeric.divide_unsigned
num_negate = Numeric.negate
num_bit_not = Numeric.bit_not
num_not = Numeric.bit_not
num_is_negative = Numeric.is_negative
num_is_zero = Numeric.is_zero

View File

@ -44,11 +44,11 @@ do
local assert = assert
local math_abs = math.abs
local math_round = math.round
local math_floor = math.floor
local math_round = math.round
local math_sign = math.sign
local math_min = math.min
local math_max = math.max
local math_min = math.min
function add.i32(a, b)
return to_u32(a + b)
@ -92,17 +92,19 @@ do
end
function min.num(a, b)
if b ~= b then
if b == b then
return math_min(a, b)
else
return b
end
return math_min(a, b)
end
function max.num(a, b)
if b ~= b then
if b == b then
return math_max(a, b)
else
return b
end
return math_max(a, b)
end
function copysign.num(lhs, rhs)
@ -117,7 +119,7 @@ do
local result = math_round(num)
if math_abs(num) % 1 == 0.5 and math_floor(math_abs(num) % 2) == 0 then
result -= math_sign(result)
result = result - math_sign(result)
end
return result
@ -332,7 +334,11 @@ do
end
function trunc.num(num)
return if num >= 0 then math.floor(num) else math.ceil(num)
if num >= 0 then
return math.floor(num)
else
return math.ceil(num)
end
end
trunc.u64_f32 = num_from_u64