Module:Rational: Difference between revisions

Plumtree (talk | contribs)
as_ratio(), a bugfix
Plumtree (talk | contribs)
m is_int() implemented
Line 199: Line 199:
local c = p.sub(a, b)
local c = p.sub(a, b)
return c.zero
return c.zero
end
-- determine whether a rational number is integer
function p.is_int(a)
if type(a) == 'number' then
return true
end
if a.nan then
return false
end
if a.inf then
return false
end
for factor, power in pairs(a) do
if type(factor) == 'number' then
if power < 0 then
return false
end
end
end
return true
end
end