Module:Rational: Difference between revisions

Plumtree (talk | contribs)
mNo edit summary
Plumtree (talk | contribs)
mNo edit summary
Line 1,330: Line 1,330:
-- return a rational number in ket notation
-- return a rational number in ket notation
-- NaN, infinity, zero values use special representations
-- NaN, infinity, zero values use special representations
function p.as_ket(a, frame, skip_many_zeros, only_numbers, sep)
function p.as_ket(a, frame, skip_many_zeros, only_numbers)
skip_many_zeros = skip_many_zeros or true
skip_many_zeros = skip_many_zeros or true
only_numbers = only_numbers or false
only_numbers = only_numbers or false
sep = sep or ' '
if type(a) == 'number' then
if type(a) == 'number' then
a = p.new(a)
a = p.new(a)
Line 1,367: Line 1,366:
if u.is_prime(i) then
if u.is_prime(i) then
if i > 2 then
if i > 2 then
template_arg = template_arg .. sep
template_arg = template_arg .. ' '
end
end
template_arg = template_arg .. (a[i] or 0)
template_arg = template_arg .. (a[i] or 0)
Line 1,375: Line 1,374:
template_arg = template_arg_without_trailing_zeros
template_arg = template_arg_without_trailing_zeros
if #template_arg > 0 then
if #template_arg > 0 then
template_arg = template_arg .. sep
template_arg = template_arg .. ' '
end
end
template_arg = template_arg .. '0<sup>' .. zeros_n .. '</sup> ' .. (a[i] or 0)
template_arg = template_arg .. '0<sup>' .. zeros_n .. '</sup> ' .. (a[i] or 0)