Difference between revisions of "Template:Mod"

From Second Life Wiki
Jump to navigation Jump to search
m
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
<includeonly>
<includeonly>{{#expr:{{#ifexpr:({{{1|0}}}) >= 2147483648|(((({{{1}}}) - 2147483648) mod ({{{2}}})) - ((-2147483648) mod ({{{2}}}))) mod ({{{2}}})|(({{{1}}}) mod ({{{2}}}))}}}}</includeonly><noinclude>
{{#ifexpr:({{{1|0}}}) >= 2147483648|
Why does this template exist? Because the internal #expr-mod function treats integers bigger then 2147483647 as negative, resulting in a useless answer. This is a partial solution, it is designed to only handles the range [2147483648, 4294967295].
{{#expr:(({{{1}}}) mod {{{2}}}) + ((-1) mod {{{2}}})}}
 
|
{{#expr:(({{{1}}}) mod {{{2}}})}}
}}
=
{{#expr:(({{{1}}}) mod {{{2}}})}}
</includeonly><noinclude>
Test: {{{{PAGENAME}}|2147483690|23}}
Test: {{{{PAGENAME}}|2147483690|23}}
</noinclude>
</noinclude>

Latest revision as of 18:05, 24 April 2007

Why does this template exist? Because the internal #expr-mod function treats integers bigger then 2147483647 as negative, resulting in a useless answer. This is a partial solution, it is designed to only handles the range [2147483648, 4294967295].

Test: 2