This is the
talk page for discussing improvements to the
Math module. |
|
Archives: 1 |
![]() | This module does not require a rating on Wikipedia's
content assessment scale. It is of interest to the following WikiProjects: | |||||||
|
This module implements a collection of related mathematical operations and number formatting tasks.
Hello, this is not enwiki problem. On bnwiki, this module sometime gives incorrect result. There is problem with "precision_format". For example, {{#invoke:Math|precision_format| 2.0004 | 3}} gives ২�000 instead of ২,০০০ ( more example, bn:Module:Math, sandbox). How can i fix this? Please feel free to edit sandbox. -- আফতাবুজ্জামান ( talk) 23:56, 2 June 2020 (UTC)
local zero_sep = lang:formatNum(1.1) formatted_num = formatted_num .. zero_sep:sub(2,2)
.
or ,
). The code assumes the local number uses English digits in which case :sub(2,2)
will extract the second character which they hope is .
or ,
. However, at bnwiki 1.1 is ১.১ and the code gets the second byte of the first digit which gives that broken Unicode symbol. A simple fix would be to change the above by commenting out or deleting the first line, and editing the second line:--local zero_sep = lang:formatNum(1.1) formatted_num = formatted_num .. '.'
{{round|0.000020004|7}}
is giving incorrect result.
আফতাবুজ্জামান (
talk)
03:02, 4 June 2020 (UTC)@
আফতাবুজ্জামান:Hmm, that seems to be a bug in lang:formatNum. Put the following in a module sandbox and test with {{#invoke:SANDBOXNAME|main}}
.
local function main() local lang = mw.getContentLanguage() local r = lang:formatNum(0.00002) return #r .. ' /' .. r .. '/' end return {main=main}
Trying this gives the results shown:
The 7 is the length (number of bytes) in the result. Each of the two bn digits is 3 bytes in UTF-8 and the dot is 1, so they add up to 7. The point of that is that there is nothing in the output that is hidden—it's only 7 bytes. I guess you could ask about that at Phabricator. Perhaps e notation is not supported in a language where it is not usually used? Is it used? Johnuniq ( talk) 03:59, 4 June 2020 (UTC)
I see that a software update since the above has changed what occurs.
bn:Module talk:খেলাঘর/Johnuniq/format used to show that lang:formatNum(0.00002)
gave the bn equivalent of "2.0" (wrong) while
here at enwiki it gave "2.0E-5". Now, both results are the equivalent of "0". Some consequences:
{{#invoke:Math|precision_format|2.0004|3}}
→ 2.000 (good){{round|0.00019|4}}
→ 0.0002 (good){{round|0.000019|5}}
→ 0{{round|0.000020004|7}}
→ 000Johnuniq ( talk) 06:26, 11 January 2021 (UTC)
![]() | This
edit request has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Please copy from Module:Math/sandbox to implement the merge of Module:PassMath per Wikipedia:Templates for discussion/Log/2021 February 28#Module:PassMath * Pppery * it has begun... 20:14, 10 March 2021 (UTC)
lang:formatNum for numbers of order -5 and smaller returns 0 (for en language). Temporary(?) fix in lua pseudocode:
if order(math.abs(value)) < -4
formatted_num = lang:formatNum(math.abs(value), noCommafy=true)
else
formatted_num = lang:formatNum(math.abs(value))
Context: Template_talk:Round#Bug_in_rounding_0.000020004?. MarMi wiki ( talk) 19:49, 26 April 2021 (UTC)
p._round function.
For 0.005 it returns: invoke 0.01, expr 0.01
For -0.005 it returns: invoke 0.00, expr -0.01
Called by: invoke:Math|precision_format|0.005|2
, expr:0.005 round 2
What type of rounding function exactly it is supposed to be? It looks like half up rounding, which doesn't match the rounding used by expr. Is that intentional? MarMi wiki ( talk) 19:10, 27 August 2023 (UTC)
This is the
talk page for discussing improvements to the
Math module. |
|
Archives: 1 |
![]() | This module does not require a rating on Wikipedia's
content assessment scale. It is of interest to the following WikiProjects: | |||||||
|
This module implements a collection of related mathematical operations and number formatting tasks.
Hello, this is not enwiki problem. On bnwiki, this module sometime gives incorrect result. There is problem with "precision_format". For example, {{#invoke:Math|precision_format| 2.0004 | 3}} gives ২�000 instead of ২,০০০ ( more example, bn:Module:Math, sandbox). How can i fix this? Please feel free to edit sandbox. -- আফতাবুজ্জামান ( talk) 23:56, 2 June 2020 (UTC)
local zero_sep = lang:formatNum(1.1) formatted_num = formatted_num .. zero_sep:sub(2,2)
.
or ,
). The code assumes the local number uses English digits in which case :sub(2,2)
will extract the second character which they hope is .
or ,
. However, at bnwiki 1.1 is ১.১ and the code gets the second byte of the first digit which gives that broken Unicode symbol. A simple fix would be to change the above by commenting out or deleting the first line, and editing the second line:--local zero_sep = lang:formatNum(1.1) formatted_num = formatted_num .. '.'
{{round|0.000020004|7}}
is giving incorrect result.
আফতাবুজ্জামান (
talk)
03:02, 4 June 2020 (UTC)@
আফতাবুজ্জামান:Hmm, that seems to be a bug in lang:formatNum. Put the following in a module sandbox and test with {{#invoke:SANDBOXNAME|main}}
.
local function main() local lang = mw.getContentLanguage() local r = lang:formatNum(0.00002) return #r .. ' /' .. r .. '/' end return {main=main}
Trying this gives the results shown:
The 7 is the length (number of bytes) in the result. Each of the two bn digits is 3 bytes in UTF-8 and the dot is 1, so they add up to 7. The point of that is that there is nothing in the output that is hidden—it's only 7 bytes. I guess you could ask about that at Phabricator. Perhaps e notation is not supported in a language where it is not usually used? Is it used? Johnuniq ( talk) 03:59, 4 June 2020 (UTC)
I see that a software update since the above has changed what occurs.
bn:Module talk:খেলাঘর/Johnuniq/format used to show that lang:formatNum(0.00002)
gave the bn equivalent of "2.0" (wrong) while
here at enwiki it gave "2.0E-5". Now, both results are the equivalent of "0". Some consequences:
{{#invoke:Math|precision_format|2.0004|3}}
→ 2.000 (good){{round|0.00019|4}}
→ 0.0002 (good){{round|0.000019|5}}
→ 0{{round|0.000020004|7}}
→ 000Johnuniq ( talk) 06:26, 11 January 2021 (UTC)
![]() | This
edit request has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Please copy from Module:Math/sandbox to implement the merge of Module:PassMath per Wikipedia:Templates for discussion/Log/2021 February 28#Module:PassMath * Pppery * it has begun... 20:14, 10 March 2021 (UTC)
lang:formatNum for numbers of order -5 and smaller returns 0 (for en language). Temporary(?) fix in lua pseudocode:
if order(math.abs(value)) < -4
formatted_num = lang:formatNum(math.abs(value), noCommafy=true)
else
formatted_num = lang:formatNum(math.abs(value))
Context: Template_talk:Round#Bug_in_rounding_0.000020004?. MarMi wiki ( talk) 19:49, 26 April 2021 (UTC)
p._round function.
For 0.005 it returns: invoke 0.01, expr 0.01
For -0.005 it returns: invoke 0.00, expr -0.01
Called by: invoke:Math|precision_format|0.005|2
, expr:0.005 round 2
What type of rounding function exactly it is supposed to be? It looks like half up rounding, which doesn't match the rounding used by expr. Is that intentional? MarMi wiki ( talk) 19:10, 27 August 2023 (UTC)