Template:Evalns/doc

Purpose
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.

Returns
If the output is not valid as input, the expression is just reproduced, enclosed in parentheses. Otherwise it returns the number returned in the evaluation of the specified expression.

So this template just has the same effect as calling  directly, except that parentheses will appear around the source expression if that expression cannot be evaluated (for example a missing parameter value without a default), avoiding the error message generated by.
 * gives.
 * gives.

Examples

 * gives.
 * gives.
 * gives.

Note: the scientific notation of result numbers are no longer a problem when these results are further inserted in other expressions. So this version no longer invalidates numbers in scientific notations, as they are directly evaluatable. The protection of parentheses is not even needed, due to numeric operator precedences for the "e" operator (which multiplies a number by a power of 10 given by a (possibly negative) number in its second operand:
 * gives.
 * gives.
 * gives.
 * gives.

Using  directly produces the same result :
 * gives.
 * gives.
 * gives.
 * gives.

Source code
(simplified and formatted, removing the "subst" parameter stuff which is also included) This first tries to evaluate the expression, which may return either a number, or a special value like INF or NAN, or an error message. Then the #ifexpr reevaluates this string : only numbers will pass, but as there's no return expression, an empty string will be returned ; if there's an evaluation error (including when evaluating INF or NAN values), only an error message will be regenerated. Finally the #if just test for the presence or not of the error message. If there's one, the parameter 1 could not be evaluated to a finite number, so the parameter is returned between parentheses ; otherwise, the parameter is reevaluted to return its value

Note that if the expression in parameter 1 is just a simple number, it will be with those zeroes stripped, and exponents will be normalized : "" = "", "" = "". Numbers are returned with at most 13 significant digits, either as integers or fractional numbers if possible, but using normalized the exponential notation for all numbers whose absolute value is lower than or higher than or equal to.