Module:ET: Difference between revisions

math.nan might be better
Tag: Reverted
Undo revision 204820 by FloraC (talk). Wait is this thing not in math?
Tag: Undo
Line 64: Line 64:
function p.backslash_ratio(et, steps)
function p.backslash_ratio(et, steps)
if et.size == 0 then
if et.size == 0 then
return math.nan
return nil
end
end
return rat.as_float(et.equave) ^ (steps / et.size)
return rat.as_float(et.equave) ^ (steps / et.size)
Line 71: Line 71:
function p.backslash_display(et, steps)
function p.backslash_display(et, steps)
if et.size == 0 then
if et.size == 0 then
return math.nan
return nil
end
end
return steps .. p.backslash_modifier(et)
return steps .. p.backslash_modifier(et)
Line 86: Line 86:
function p.cents(et, steps)
function p.cents(et, steps)
if et.size == 0 then
if et.size == 0 then
return math.nan
return nil
end
end
steps = steps or 1
steps = steps or 1
Line 95: Line 95:
function p.hekts(et, steps)
function p.hekts(et, steps)
if et.size == 0 then
if et.size == 0 then
return math.nan
return nil
end
end
steps = steps or 1
steps = steps or 1
Line 107: Line 107:
towards = towards or 0
towards = towards or 0
if et.size == 0 then
if et.size == 0 then
return 0
return nil
end
end
local exact = math.log(ratio) / math.log(rat.as_float(et.equave)) * et.size
local exact = math.log(ratio) / math.log(rat.as_float(et.equave)) * et.size