Template:Evalns/doc
This is a documentation subpage for Template:Evalns. It contains usage information, categories, and other content that is not part of the original template page. |
EVALuate, but No Scientific notation.
This template can be used to evaluate an expression, if the result has to be suitable as input for further expressions. If the output is not valid as input, the expression is just reproduced, enclosed in parentheses. Note that numbers in scientific notations were initially NOT suitable for input of expressions, hence the name of this template. This is no longer the case as demonstrated below.
{{evalns|3*4}}
gives 12.{{evalns|1234567890*12}}
gives 14814814680.{{evalns|1234567890*1234567890}}
gives 1.5241578750191E+18.{{eval|2*{{evalns|1234567890*1234567890}}}}
gives 3.0483157500382E+18.
The case where evalns returns the input expression in parentheses is when it detects an error when trying to evaluate it as an numeric expression:
{{eval|2*{{evalns|1234567890*1x2.34567890}}}}
gives [expression “2*(1234567890*1x2.34567890)” is wrong].
But it cannot detect all errors:
{{eval|2*{{evalns|1234567890*1.2}}}}
gives 2962962936.{{eval|2*{{evalns|1234567890*1.2.3}}}}
also gives 2962962936 !{{eval|2*{{evalns|1234567890*1.2.3.4567890}}}}
also gives 2962962936 !{{eval|2*{{evalns|1234567890*1.2.3.4.5.6.7.8.9.0}}}}
also gives 2962962936 !{{eval|2*{{evalns|1234567890*1.2.3.4.5.6.7.8.e-1}}}}
also gives 296296293.6 !{{eval|2*{{evalns|1234567890*1.2e3.4.5.6.7.8.e-1}}}}
now gives 744262639600.42 !{{eval|2*{{evalns|1234567890*1.2e3.e.5.6.7.8.e-1}}}}
now gives 11795767909058 !{{eval|2*{{evalns|1234567890*1.2e3.4e5.6.7.8.e-1}}}}
now gives 2.962962936E+17 !
In other words, the evaluation of constant numbers stops at the second dot found, and the rest is simply ignored if it only contains superfluous characters that may be acceptable in constant numbers, but if there's a "e", it is treated to compute a "strange" product... This just reveals that in fact the scientific notation is still not recognized as such, but instead "e" is handled like a binary operator between two numbers that are evaluated separately.