Module:Rational: Difference between revisions
m You wouldn't need overflow protection if it could do m * n Tag: Undo |
All the special cases in as_ket make no sense |
||
Line 1,366: | Line 1,366: | ||
end | end | ||
-- return a rational number in | -- return a string of a rational number in monzo notation | ||
-- | -- calling Template: Monzo | ||
function p.as_ket(a, frame, skip_many_zeros, only_numbers) | function p.as_ket(a, frame, skip_many_zeros, only_numbers) | ||
if skip_many_zeros == nil then | if skip_many_zeros == nil then | ||
Line 1,376: | Line 1,376: | ||
a = p.new(a) | a = p.new(a) | ||
end | end | ||
-- special | |||
if a.nan then | -- special cases | ||
return " | if a.nan or a.inf or a.zero or a.sign < 0 then | ||
return "n/a" | |||
end | end | ||
-- | |||
-- regular case: positive finite ratio | |||
local s = "" | |||
-- preparing the argument | -- preparing the argument | ||
local max_prime = p.max_prime(a) | local max_prime = p.max_prime(a) |