Jump to content

Template:One In X: Difference between revisions

From RiskiPedia
User-friendly display of a fractional risk
 
Add case for zero chance
Line 1: Line 1:
<noinclude>
<noinclude>
This is the "One in X" template. It uses the Parser Function extension functions to convert a floating point number into a user-friendly "x in ten / hundred / thousand / etc"
This is the "One in X" template. It uses the Parser Function extension functions to convert a floating point number into a user-friendly "x in ten / hundred / thousand / etc"
</noinclude><includeonly>{{#ifexpr: {{{1}}} < 1e-6 | less than one in a million |  
</noinclude><includeonly>{{ifexpr: {{1}} == 0 | zero (no chance) |
  {{#ifexpr: {{{1}}} < 1e-6 | less than one in a million |  
   {{#ifexpr: {{{1}}} < 1e-3 | {{#expr: {{{1}}}*1e6 round 0}} in a million |
   {{#ifexpr: {{{1}}} < 1e-3 | {{#expr: {{{1}}}*1e6 round 0}} in a million |
   {{#ifexpr: {{{1}}} < 1e-2 | {{#expr: {{{1}}}*1e3 round 0}} in a thousand |
   {{#ifexpr: {{{1}}} < 1e-2 | {{#expr: {{{1}}}*1e3 round 0}} in a thousand |
   {{#ifexpr: {{{1}}} < 1e-1 | {{#expr: {{{1}}}*1e2 round 0}} in a hundred |
   {{#ifexpr: {{{1}}} < 1e-1 | {{#expr: {{{1}}}*1e2 round 0}} in a hundred |
   {{#ifexpr: {{{1}}} < 1 | {{#expr: {{{1}}}*100 round 0}} percent |
   {{#ifexpr: {{{1}}} < 1 | {{#expr: {{{1}}}*100 round 0}} percent |
   100 percent (absolutely certain) }} }} }} }} }}</includeonly>
   100 percent (absolutely certain) }} }} }} }} }} }}</includeonly>

Revision as of 02:44, 30 August 2025

This is the "One in X" template. It uses the Parser Function extension functions to convert a floating point number into a user-friendly "x in ten / hundred / thousand / etc"