Module:ED intro: Difference between revisions

Ganaram inukshuk (talk | contribs)
Removed precision cap of 3 DPs
Actual fix
Line 33: Line 33:
local ed = ed or 12
local ed = ed or 12
-- Exactly or about? Round to 3 DPs
-- Exactly or about? Check up to three significant figures
local edstep_size = 1200 / ed
local edstep_size = 1200 / ed
local edstep_size_rounded = utils._round(edstep_size, 3)
local edstep_size_rounded = utils._round(edstep_size, 3)
Line 50: Line 50:
intro_text = string.gsub(intro_text, "''k''", ed)
intro_text = string.gsub(intro_text, "''k''", ed)
intro_text = string.gsub(intro_text, "exactly/about", (is_exact and "exactly" or "about"))
intro_text = string.gsub(intro_text, "exactly/about", (is_exact and "exactly" or "about"))
intro_text = string.gsub(intro_text, "''s''", string.format("%d", edstep_size))
intro_text = string.gsub(intro_text, "''s''", utils._round (edstep_size, 3))
intro_text = string.gsub(intro_text, "''kth''", ord._ordinal(ed))
intro_text = string.gsub(intro_text, "''kth''", ord._ordinal(ed))
Line 60: Line 60:
local ed = ed or 13
local ed = ed or 13
-- Exactly or about? Round to 3 DPs
-- Exactly or about? Check up to three significant figures
local equave_in_cents = math.log(3) * 1200
local equave_in_cents = math.log(3) * 1200
local edstep_size = equave_in_cents / math.log(2) / ed
local edstep_size = equave_in_cents / math.log(2) / ed
Line 78: Line 78:
intro_text = string.gsub(intro_text, "''k''", ed)
intro_text = string.gsub(intro_text, "''k''", ed)
intro_text = string.gsub(intro_text, "exactly/about", (is_exact and "exactly" or "about"))
intro_text = string.gsub(intro_text, "exactly/about", (is_exact and "exactly" or "about"))
intro_text = string.gsub(intro_text, "''s''", string.format("%d", edstep_size))
intro_text = string.gsub(intro_text, "''s''", utils._round (edstep_size, 3))
intro_text = string.gsub(intro_text, "''kth''", ord._ordinal(ed))
intro_text = string.gsub(intro_text, "''kth''", ord._ordinal(ed))
Line 88: Line 88:
local ed = ed or 7
local ed = ed or 7
-- Exactly or about? Round to 3 DPs
-- Exactly or about? Check up to three significant figures
local equave_in_cents = math.log(3/2) * 1200
local equave_in_cents = math.log(3/2) * 1200
local edstep_size = equave_in_cents / math.log(2) / ed
local edstep_size = equave_in_cents / math.log(2) / ed
Line 106: Line 106:
intro_text = string.gsub(intro_text, "''k''", ed)
intro_text = string.gsub(intro_text, "''k''", ed)
intro_text = string.gsub(intro_text, "exactly/about", (is_exact and "exactly" or "about"))
intro_text = string.gsub(intro_text, "exactly/about", (is_exact and "exactly" or "about"))
intro_text = string.gsub(intro_text, "''s''", string.format("%d", edstep_size))
intro_text = string.gsub(intro_text, "''s''", utils._round (edstep_size, 3))
intro_text = string.gsub(intro_text, "''kth''", ord._ordinal(ed))
intro_text = string.gsub(intro_text, "''kth''", ord._ordinal(ed))
Line 117: Line 117:
local harmonic = harmonic or 4
local harmonic = harmonic or 4
-- Exactly or about? Round to 3 DPs
-- Exactly or about? Check up to three significant figures
local equave_in_cents = math.log(harmonic) * 1200  
local equave_in_cents = math.log(harmonic) * 1200  
local edstep_size = equave_in_cents / math.log(2) / ed
local edstep_size = equave_in_cents / math.log(2) / ed
Line 135: Line 135:
intro_text = string.gsub(intro_text, "''k''", ed)
intro_text = string.gsub(intro_text, "''k''", ed)
intro_text = string.gsub(intro_text, "exactly/about", (is_exact and "exactly" or "about"))
intro_text = string.gsub(intro_text, "exactly/about", (is_exact and "exactly" or "about"))
intro_text = string.gsub(intro_text, "''s''", string.format("%d", edstep_size))
intro_text = string.gsub(intro_text, "''s''", utils._round (edstep_size, 3))
intro_text = string.gsub(intro_text, "''kth''", ord._ordinal(ed))
intro_text = string.gsub(intro_text, "''kth''", ord._ordinal(ed))
intro_text = string.gsub(intro_text, "hth", ord._ordinal(harmonic))
intro_text = string.gsub(intro_text, "hth", ord._ordinal(harmonic))
Line 148: Line 148:
local ratio = ratio or rat.new(9,4)
local ratio = ratio or rat.new(9,4)
-- Exactly or about? Round to 3 DPs
-- Exactly or about? Check up to three significant figures
local equave_in_cents = rat.cents(ratio)
local equave_in_cents = rat.cents(ratio)
local edstep_size = equave_in_cents / ed
local edstep_size = equave_in_cents / ed
Line 166: Line 166:
intro_text = string.gsub(intro_text, "''k''", ed)
intro_text = string.gsub(intro_text, "''k''", ed)
intro_text = string.gsub(intro_text, "exactly/about", (is_exact and "exactly" or "about"))
intro_text = string.gsub(intro_text, "exactly/about", (is_exact and "exactly" or "about"))
intro_text = string.gsub(intro_text, "''s''", string.format("%d", edstep_size))
intro_text = string.gsub(intro_text, "''s''", utils._round (edstep_size, 3))
intro_text = string.gsub(intro_text, "''kth''", ord._ordinal(ed))
intro_text = string.gsub(intro_text, "''kth''", ord._ordinal(ed))
intro_text = string.gsub(intro_text, "''p/q''", rat.as_ratio(ratio))
intro_text = string.gsub(intro_text, "''p/q''", rat.as_ratio(ratio))
Line 178: Line 178:
local cents = cents or 97.5
local cents = cents or 97.5
-- Exactly or about? Round to 3 DPs
-- Exactly or about? Check up to three significant figures
local edstep_size = cents / ed
local edstep_size = cents / ed
local edstep_size_rounded = utils._round(edstep_size, 3)
local edstep_size_rounded = utils._round(edstep_size, 3)
Line 195: Line 195:
intro_text = string.gsub(intro_text, "''k''", ed)
intro_text = string.gsub(intro_text, "''k''", ed)
intro_text = string.gsub(intro_text, "exactly/about", (is_exact and "exactly" or "about"))
intro_text = string.gsub(intro_text, "exactly/about", (is_exact and "exactly" or "about"))
intro_text = string.gsub(intro_text, "''s''", string.format("%d", edstep_size))
intro_text = string.gsub(intro_text, "''s''", utils._round (edstep_size, 3))
intro_text = string.gsub(intro_text, "''c''", cents)
intro_text = string.gsub(intro_text, "''c''", cents)