Jump to content

Template:Eval

From Meta, a Wikimedia project coordination wiki
{{#if:{{#ifexpr:{{{1}}}}}|[expression “{{{1}}}” is wrong]|{{{{{subst|}}}#expr:{{{1}}}}}}}
Template documentation


Usage

[edit]
Normal evaluation
  • ‟{{eval|3 / 4}}” gives ‟0.75”.
  • ‟{{eval|3 * 4}}” gives ‟12”.
  • ‟{{eval|3 + 4}}” gives ‟7”.
  • ‟{{eval|3 - 4}}” gives ‟-1”.
  • ‟{{eval|3 mod 4}}” gives ‟3”.
Error handling
  • ‟{{eval|3 / 0}}” gives ‟[expression “3 / 0” is wrong]”, because division by 0 is undefined.
  • ‟{{eval|1 + {{eval|3 / 0}}}}” gives ‟[expression “1 + [expression “3 / 0” is wrong]” is wrong]”, this is a case of nested error messages.