Module:Rational: Difference between revisions

Plumtree (talk | contribs)
m Bugfix
Plumtree (talk | contribs)
mNo edit summary
Line 328: Line 328:
local unparsed = frame.args[1] or '1'
local unparsed = frame.args[1] or '1'
-- rational form
-- rational form
local sign, n, _m, m = unparsed:match('(%-?)%s*(%d*)%s*(/%s*(%d*))')
local sign, n, _m, m = unparsed:match('(%-?)%s*(%d+)%s*(/%s*(%d+))')
if n == nil then
if n == nil then
-- integer form
-- integer form
sign, n = unparsed:match('(%-?)%s*(%d*)')
sign, n = unparsed:match('(%-?)%s*(%d+)')
if n == nil then
if n == nil then
-- parsing failure
-- parsing failure