Jump to content

Module:ConvertNumeric and Module:ConvertNumeric/sandbox: Difference between pages

(Difference between pages)
Page 1
Page 2
Content deleted Content added
please don't use tricky syntax: stick to boring stuff that works
 
arg
 
Line 3: Line 3:
-- When editing, preview with: [[Module_talk:ConvertNumeric/testcases]]
-- When editing, preview with: [[Module_talk:ConvertNumeric/testcases]]
-- First, edit [[Module:ConvertNumeric/sandbox]], then preview with [[Module_talk:ConvertNumeric/sandbox/testcases]]
-- First, edit [[Module:ConvertNumeric/sandbox]], then preview with [[Module_talk:ConvertNumeric/sandbox/testcases]]
require('strict')
require[[strict]]


local ones_position = {
local ones_position = {
Line 346: Line 346:
local mantissa = num:gsub("^%-?(%d*)%.?(%d*)%-?[Ee][+%-]?%d+$", "%1%2")
local mantissa = num:gsub("^%-?(%d*)%.?(%d*)%-?[Ee][+%-]?%d+$", "%1%2")
if negative and decimal_pos then decimal_pos = decimal_pos - 1 end
if negative and decimal_pos then decimal_pos = decimal_pos - 1 end
if not decimal_pos then decimal_pos = #mantissa + 1 end
decimal_pos = decimal_pos or #mantissa + 1


-- Remove leading zeros unless decimal point is in first position
-- Remove leading zeros unless decimal point is in first position
Line 498: Line 498:
else
else
numstr = numeral_to_english_less_100(numerator)
numstr = numeral_to_english_less_100(numerator)
denstr = dendata.plural
denstr = dendata.plural or (sp_us and dendata.us or dendata[1]) .. 's'
if not denstr then
denstr = (sp_us and dendata.us or dendata[1]) .. 's'
end
end
end
if finished then
if finished then