Difference between revisions of "Template:Sqrt"
From Twilight Heroes Wiki
(New page: <includeonly>{{#if:{{{1}}}| {{#expr:({{#expr:({{#expr:({{#expr:({{#expr:1 + {{floor|{{{1}}}/20}}}}+{{{1}}}/{{#expr:1 + {{floor|{{{1}}}/20}}}})/2}}+{{{1}}}/{{#expr:({{#expr:1 + {{floor|{{{1...) |
|||
(One intermediate revision by the same user not shown) | |||
Line 15: | Line 15: | ||
*:{{#expr: {{sqrt|121}} round 2}} | *:{{#expr: {{sqrt|121}} round 2}} | ||
− | [[Category:Templates]]</noinclude> | + | [[Category:Utility Templates|{{PAGENAME}}]]</noinclude> |
Latest revision as of 00:56, 22 February 2010
Borrowed from KoL wiki, this template gives an approximation to the square root of a number. Created as a work-around to the current shortcomings of the wiki's parsers.
This uses the Babylonian algorithm for computing a square root. The result is the fifth iterate obtained by this method, using the value 1+floor(input/20)
as the seed value. This value is only an approximation, as the examples below should demonstrate, but the inaccuracies will not show up until after the 6th decimal digit for values likely to be passed to the template. Rounding the value, as indicated in the last example, is suggested.
Examples
- {{sqrt|537.5818355}}
- 23.185811081349
- {{sqrt|4}}
- 2.0000000929223
- {{sqrt|121}}
- 11.000000000778
- {{#expr: {{sqrt|121}} round 2}}
- 11