Jump to content

Module talk:Formatnum

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by RexxS (talk | contribs) at 16:20, 22 October 2019 (language:formatNum(tonumber(number),…): caps). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

language:formatNum(tonumber(number),…)

If I read the code correctly, then tonumber(number) is already computed and stored in the variable named “value”. Incnis Mrsi (talk) 09:55, 22 October 2019 (UTC)[reply]

@Incnis Mrsi: It's true that the variable value stores the numeric value of the parameter passed as number. However, if you read line 44, the mw.language:formatNum() call doesn't handle exponents properly. The lines 41 to 52 convert number to a string, then if there is an exponent, it stores the significand as a string back into number and the exponent in exponent. So by the time the code reaches lines 84 or 86 the string value in 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 mw.language:formatNum(). Writing language:formatNum(value, ...) wouldn't work properly if the number passed contained an exponent. Hope that makes sense. --RexxS (talk) 16:18, 22 October 2019 (UTC)[reply]