Module:Convert: Difference between revisions
Jump to navigation
Jump to search
Content added Content deleted
(allow conversion between different unit types for certain whitelisted exceptions (torque/energy); emulate MediaWiki's template handling by accepting and multiple spaces in a unit name) |
(fix valid_number check to account for Scribunto using 'nan' or 'inf' for problem numbers) |
||
Line 639: | Line 639: | ||
local function valid_number(num) |
local function valid_number(num) |
||
-- Return true if num is a valid number. |
-- Return true if num is a valid number. |
||
-- In Scribunto (different from some standard Lua), when expressed as a string, |
|||
-- Expressed as a string, overflow or other problems are indicated with |
|||
-- text like " |
-- overflow or other problems are indicated with text like "inf" or "nan" |
||
-- which are regarded as invalid here (each contains "n"). |
|||
if type(num) == 'number' and tostring(num):find(' |
if type(num) == 'number' and tostring(num):find('n', 1, true) == nil then |
||
return true |
return true |
||
end |
end |