summaryrefslogtreecommitdiff
path: root/xmake/core/base/math.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2020-06-23 22:37:44 +0800
committerGitHub <[email protected]>2020-06-23 22:37:44 +0800
commitc18d15eb89116a0f3ce96bd56f3ccf861849f6ec (patch)
tree52b63db3274349f9a41872414208c7c30058cfd7 /xmake/core/base/math.lua
parent53df324acd9c7432336a5894ceef578daa1ce38d (diff)
parent18bded45c229f5580c13fc8b4afc5edb6f18819a (diff)
Merge pull request #857 from xmake-io/toolchain
Improve toolchain to support host and cross toolchains at same time
Diffstat (limited to 'xmake/core/base/math.lua')
-rw-r--r--xmake/core/base/math.lua14
1 files changed, 3 insertions, 11 deletions
diff --git a/xmake/core/base/math.lua b/xmake/core/base/math.lua
index 2cd53a21f..c46982328 100644
--- a/xmake/core/base/math.lua
+++ b/xmake/core/base/math.lua
@@ -24,16 +24,14 @@ local math = math or {}
-- init constants
math.nan = math.log(-1)
math.e = math.exp(1)
+math.inf = 1/0 -- @see http://lua-users.org/wiki/InfAndNanComparisons
-- check a number is int
--
-- @returns true for int, otherwise false
--
function math:isint()
-
- -- check
assert(type(self) == "number", "number expacted")
-
return self == math.floor(self) and self ~= math.huge and self ~= -math.huge
end
@@ -42,13 +40,10 @@ end
-- @returns 1 for inf, -1 for -inf, otherwise false
--
function math:isinf()
-
- -- check
assert(type(self) == "number", "number expacted")
-
- if self == math.huge then
+ if self == math.inf then
return 1
- elseif self == -math.huge then
+ elseif self == -math.inf then
return -1
else
return false
@@ -60,10 +55,7 @@ end
-- @returns true for nan, otherwise false
--
function math:isnan()
-
- -- check
assert(type(self) == "number", "number expacted")
-
return self ~= self
end