Mabinogi World Wiki is brought to you by Coty C., 808idiotz, our other patrons, and contributors like you!!
Want to make the wiki better? Contribute towards getting larger projects done on our Patreon!

Template:Fns

From Mabinogi World Wiki

Forced Numerical Sorting (Fns)

For a template that shows the hidden sort key see Template:UFns.

This template takes an unformatted number as input and returns a hidden sort key followed by a displayed, formatted and rounded off integer of the inputted number. The resulting displayed integer (but not the sort key) will have commas for thousand seperators added. Any hyphen used as a negative sign in front of the inputted number is converted into a true negative sign (which is easier to see) but only in front of the resulting displayed integer. The template can be used to input a number which is to be part of some data consisting of at least that number (rounded to the nearest integer) and possibly having non-numerical characters trailing it. When the data is added to a sortable list or table column then the hidden sort key can be used to force a numerical sort where otherwise an alphabetical sort will occur. For example, using "{{Fns|9000}}" or "{{Fns|9000}}text" works but using "{{Fns|9000text}}" will produce an error message and using "text{{Fns|9000}}" will not sort correctly (unless the "text", in front of the number, is exactly the same for each data in the sortable list or table column).

Note:

  1. A real number, or an equation resulting in a real number, can be entered into this template but they will be rounded off to the nearest whole number (i.e., an integer will still be used to generate the result). The same hidden sort key will be generated whether the inputted number is an integer or a real number rounded off to the same integer. Similarly the resulting displayed integer will be the same whether the inputted number is an integer or a real number that will round off to the same integer.
  2. The result of this template is a text string and using that result as the input into an expression or template that requires an integer or real number will produce an error message.


  • Usage:
{{Fns|unformatted number}}
  1. Where the unformatted number is an integer or real number (with a positive, a negative or no sign) without any commas as thousand seperators.
  2. Using "{{Fns}}" will result in a "000000000000&0", as that is the default result for this template.
  3. Using "{{Fns|}}" will result in an error message.
  4. Examples:
    • "{{Fns|12345678}}" will produce a hidden sort key of "000012345678&" followed by the displayed, formatted integer "000012345678&12,345,678".
    • "{{Fns|-12345678}}" will produce a hidden sort key of "-999987654321&" followed by the displayed, formatted integer "-999987654322&−12,345,678".
    • "{{Fns|12345678.901}}" will produce a hidden sort key of "000012345679&" followed by the displayed, formatted integer "000012345679&12,345,679".
    • "{{Fns|12345678.201}}" will produce a hidden sort key of "000012345678&" followed by the displayed, formatted integer "000012345678&12,345,678" (this result is exactly the same as that of the first example given above, the inputted real number in this example has been rounded down to the same integer inputted in the first example).


  • Input:
  1. This template will not accept numbers given in scientific notation, e.g., "1.23E+09".
  2. This template will accept integers with up to 12 digits and real numbers with up to 12 digits before the decimal point (any real number with digits after the decimal point will be rounded off to the nearest integer), e.g., "123456789012" and "123456789012.123" will both give 123456789012&123,456,789,012. Numbers greater than "999999999999" and less than "-999999999999" will result in an error message, e.g., "{{Fns|1234567890123}}" will result in this error message "Don't input a number > 999999999999 or < −999999999999!".
  3. Except for using a positive sign (only in front of a number), a hyphen as a negative sign (only in front of a number) or a single decimal point (anywhere in a number), only the digits from 0 to 9 can be part of a number used by this template. For example, inputting "+1236.565", "50", "0.65" and "-9656000" into this template will result in, respectively, "000000001237&1,237", "000000000050&50", "000000000001&1" and "-999990344000&−9,656,000" but inputting "+1,236.565", "50g", "0.65%" and "-9,656,000" will result in an error message.
  4. Mathematical equations and conditional statements that are supported for expressions, on Mabinogi World Wiki, may be inputted into this template, with or without being included in an expression. A mathematical equation, conditional statement or expression that is inputted into this template will be calculated first, then the result rounded off to the nearest integer and then converted.
    • Examples;
      • "{{Fns|-1235.786*100}}" results in "-999999876421&−123,579", note that "{{#expr:-1235.786*100}}" results in "-123578.6".
      • "{{Fns|{{#expr:-1235.786*100}}}}" results in "-999999876421&−123,579", note that "{{#expr:{{#expr:-1235.786*100}}}}" results in "-123578.6".
      • "{{Fns|-1235.786round2}}" results in "-999999998764&−1,236", note that "{{#expr:-1235.786round2}}" results in "-1235.79".
      • "{{Fns|(10<5)+19.85}}" results in "000000000020&20", note that "{{#expr:(10<5)+19.85}}" results in "19.85".
      • "{{Fns|(10>5)+19.85}}" results in "000000000021&21", note that "{{#expr:(10>5)+19.85}}" results in "20.85".


  • Related Information About Mabinogi World Wiki:

The term expression is used here to mean a mathematical equation requiring the input of one or more numbers (integers and/or real) that results in a number (integer or real). Inputted numbers with non-significant leading zeroes to the left of the decimal point and/or non-significant trailing zeroes to the right of the decimal point will be treated as if those non-significant zeroes did not exist (e.g., "00001003.0405000" will be treated as if it had been entered as "1003.0405").

  1. Numbers calculated by an expression used on Mabinogi World Wiki, that give results between "−0.001" and "0.001" (excluding zero), will probably be given in scientific notation, e.g., "{{#expr:1/100000}}" is not given as "0.00001" but as "1.0E-5". The actual trigger for when scientific notation is used does not appear to be clear cut, e.g., "{{#expr:1/10000}}" is usually given as "0.0001" but ocassionally is given as "1.0E-4". However, numbers from "−1" to "−0.001" and "0.001" to "1", never appear to be given as scientific notation. Remember, that this template, or any expression used on Mabinogi World Wiki, will not accept numbers in scientific notation.
  2. A number outputted by an expression used on Mabinogi World Wiki, will be rounded off to the first 12 digits, e.g., "{{#expr:12345678901234.123*1}}" will result in "12345678901234".
  3. Any large enough number outputted from an expression on Mabinogi World Wiki will give the result in scientific notation (and rounded to the first 12 digits), e.g., "{{#expr:123456789012345678901234.123*1}}" will output "1.2345678901235E+23". Remember, that this template, or any expression used on Mabinogi World Wiki, will not accept numbers in scientific notation.


  • Code:
{{ #ifexpr: 
      ( ( ( {{{1|0}}} ) round 0 ) > 999999999999 ) 
      or 
      ( ( ( {{{1|0}}} ) round 0 ) < -999999999999 ) 
   |
      '''<font color="red">Don't input a number > 999999999999 or < −999999999999!</font>'''
   | 
      {{ #ifexpr: 
            ( ( {{{1|0}}} ) round 0 ) = 0 
         |
            <span style="display:none">
            {{ padleft: 
               0 
            | 12 | 0 }}
            &
            </span>
            0
         | 
            {{ #ifexpr: 
                  ( ( {{{1|0}}} ) round 0 ) < 0 
               |
                  <span style="display:none">
                  -
                  {{ padleft: 
                     {{ #expr: 
                        999999999999 + ( ( {{{1|0}}} ) round 0 ) 
                     }} 
                  | 12 | 0 }}
                  &
                  </span>
                  −
                  {{ formatnum: 
                     {{ #expr: 
                        -( ( {{{1|0}}} ) round 0 ) 
                     }} 
                  }}
               |
                  <span style="display:none">
                  {{ padleft: 
                     {{ #expr: 
                        ( ( {{{1|0}}} ) round 0 ) 
                     }} 
                  | 12 | 0 }}
                  &
                  </span>
                  {{ formatnum: 
                     {{ #expr: 
                        ( ( {{{1|0}}} ) round 0 ) 
                     }} 
                  }}
            }} 
      }} 
 }}