Module talk:Formatnum: Difference between revisions

Content deleted Content added
Line 6:
:
: {{re|Incnis Mrsi}} It's true that the variable {{var|value}} stores the numeric value of the parameter passed as {{var|number}}. However, if you read line 44, the <code>mw.language:formatNum()</code> call doesn't handle exponents properly. The lines 41 to 52 convert {{var|number}} to a string, then if there is an exponent, it stores the [[significand]] as a string back into {{var|number}} and the exponent in {{var|exponent}}. So by the time the code reaches lines 84 or 86 the string value in {{var|number}} may or may not be the same as that passed into the function. So it's necessary to again convert that string back to a number in order to use <code>mw.language:formatNum()</code>. Writing <code>language:formatNum(value, ...)</code> wouldn't work properly if the number passed contained an exponent. Hope that makes sense. --[[User:RexxS|RexxS]] ([[User talk:RexxS|talk]]) 16:18, 22 October 2019 (UTC)
:: Ah, got it{{snd}}the variable may be reassigned with <code>number = string.sub(number, 1, pos - 1)</code>. [[User:Incnis Mrsi|Incnis Mrsi]] ([[User talk:Incnis Mrsi|talk]]) 17:11, 22 October 2019 (UTC)