Module:Rational: Difference between revisions

Plumtree (talk | contribs)
m from_continued_fraction() implemented
Plumtree (talk | contribs)
mNo edit summary
Line 5: Line 5:
function p.new(n, m)
function p.new(n, m)
m = m or 1
m = m or 1
if n == 0 then
if n == 0 and m == 0 then
if m == 0 then
return { nan = true }
return { nan = true }
elseif n == 0 then
else
return { zero = true, sign = u.signum(m) }
return { zero = true, sign = u.signum(m) }
elseif m == 0 then
end
return { inf = true, sign = u.signum(n) }
else
if m == 0 then
return { inf = true, sign = u.signum(n) }
end
end
end
local sign = u.signum(n) * u.signum(m)
local sign = u.signum(n) * u.signum(m)