Style touch ups
This commit is contained in:
parent
0f96d430b6
commit
951ee169a2
@ -25,7 +25,7 @@ local math_pow = math.pow
|
|||||||
local table_freeze = table.freeze
|
local table_freeze = table.freeze
|
||||||
|
|
||||||
local from_u32, into_u32, from_u64, into_u64
|
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
|
local num_is_negative, num_is_zero, num_is_equal, num_is_less_unsigned, num_is_greater_unsigned
|
||||||
|
|
||||||
-- TODO: Eventually support Vector3
|
-- TODO: Eventually support Vector3
|
||||||
@ -231,7 +231,7 @@ function Numeric.divide_signed(lhs, rhs)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Numeric.negate(value)
|
function Numeric.negate(value)
|
||||||
return num_add(num_bit_not(value), K_ONE)
|
return num_add(num_not(value), K_ONE)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Numeric.bit_and(lhs, rhs)
|
function Numeric.bit_and(lhs, rhs)
|
||||||
@ -393,7 +393,7 @@ num_subtract = Numeric.subtract
|
|||||||
num_multiply = Numeric.multiply
|
num_multiply = Numeric.multiply
|
||||||
num_divide_unsigned = Numeric.divide_unsigned
|
num_divide_unsigned = Numeric.divide_unsigned
|
||||||
num_negate = Numeric.negate
|
num_negate = Numeric.negate
|
||||||
num_bit_not = Numeric.bit_not
|
num_not = Numeric.bit_not
|
||||||
|
|
||||||
num_is_negative = Numeric.is_negative
|
num_is_negative = Numeric.is_negative
|
||||||
num_is_zero = Numeric.is_zero
|
num_is_zero = Numeric.is_zero
|
||||||
|
@ -44,11 +44,11 @@ do
|
|||||||
|
|
||||||
local assert = assert
|
local assert = assert
|
||||||
local math_abs = math.abs
|
local math_abs = math.abs
|
||||||
local math_round = math.round
|
|
||||||
local math_floor = math.floor
|
local math_floor = math.floor
|
||||||
|
local math_round = math.round
|
||||||
local math_sign = math.sign
|
local math_sign = math.sign
|
||||||
local math_min = math.min
|
|
||||||
local math_max = math.max
|
local math_max = math.max
|
||||||
|
local math_min = math.min
|
||||||
|
|
||||||
function add.i32(a, b)
|
function add.i32(a, b)
|
||||||
return to_u32(a + b)
|
return to_u32(a + b)
|
||||||
@ -92,17 +92,19 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
function min.num(a, b)
|
function min.num(a, b)
|
||||||
if b ~= b then
|
if b == b then
|
||||||
|
return math_min(a, b)
|
||||||
|
else
|
||||||
return b
|
return b
|
||||||
end
|
end
|
||||||
return math_min(a, b)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function max.num(a, b)
|
function max.num(a, b)
|
||||||
if b ~= b then
|
if b == b then
|
||||||
|
return math_max(a, b)
|
||||||
|
else
|
||||||
return b
|
return b
|
||||||
end
|
end
|
||||||
return math_max(a, b)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function copysign.num(lhs, rhs)
|
function copysign.num(lhs, rhs)
|
||||||
@ -117,7 +119,7 @@ do
|
|||||||
local result = math_round(num)
|
local result = math_round(num)
|
||||||
|
|
||||||
if math_abs(num) % 1 == 0.5 and math_floor(math_abs(num) % 2) == 0 then
|
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
|
end
|
||||||
|
|
||||||
return result
|
return result
|
||||||
@ -332,7 +334,11 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
function trunc.num(num)
|
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
|
end
|
||||||
|
|
||||||
trunc.u64_f32 = num_from_u64
|
trunc.u64_f32 = num_from_u64
|
||||||
|
Loading…
x
Reference in New Issue
Block a user