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!
User:ZRoc/trunc
About This Page
This page is a sub-page of my user page and is used by me to test a templates.
IMPORTANT: Please don't edit this page without talking to me first. Leave messages on User_talk:ZRoc rather than on this page's talk/discussion page, as it doesn't automatically tell me if this page gets new messages.
For other sub-pages see the list on my user page.
Users With Permission to Edit This Page
- None
Users Never Permitted to Edit This Page
Description
Gives the truncated value of a real number (removes all the digits following a decimal point). Note that, integers can be entered but obviously will not be truncated.
- Usage:
{{User:ZRoc/trunc|unformatted number}}
- Where unformatted number is a number (with a positive, negative or no sign) without commas as thousand seperators.
- Not entering a pipe character and a number, i.e., "{{User:ZRoc/trunc}}", will result in a "0", the default result for this template.
- Entering a pipe character but not a number, i.e., "{{User:ZRoc/trunc|}}" will result in an error message.
- Examples:
- "{{User:ZRoc/trunc|-12356.8946}}" will result in "-12356"
- "{{User:ZRoc/trunc|1.02}}" will result in "1".
- "{{User:ZRoc/trunc|1.99}}" will result in "1".
- "{{User:ZRoc/trunc|0.0002}}" will result in "0".
- Input:
- This template will not accept numbers given in scientific notation, e.g., "1.23E+23".
- When inputting a single value, it can include 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) and must include a digit or digits from "0" to "9". For example, inputting "-3120360.32", "1950", "30.002" and "+0" will respectively result in "-3120360", "1950", "30" and "0" but inputting "-3,120,360.32", "1950g", "30.002%" and "+" will result in an error message.
- Mathematical equations and conditional statements, that are supported on Mabinogi World Wiki, for input into expressions can 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 and then the result will be truncated.
- Examples;
- "{{User:ZRoc/trunc|{{#expr:-1235.786*100}}}}", where "{{#expr:-1235.786*100}} = -123578.6" and then truncating this gives "-123478".
- "{{User:ZRoc/trunc|-1235.786*100}}", where "-1235.786*100 = -123578.6" and then truncating this gives "-123578".
- "{{User:ZRoc/trunc|-1235.786round0}}", where "-1235.786round0 = -1236" and then truncating this gives "-1236".
- "{{User:ZRoc/trunc|(10<5)+19.85}}", where "(10<5) = false = 0", so that "0+19.85 = 19.85" and then truncating this gives "19".
- "{{User:ZRoc/trunc|(10>5)+19.85}}", where "(10>5) = true = 1", so that "1+19.85 = 20.85" and then truncating this gives "20".
- Examples;
- Related Information About Mabinogi World Wiki:
- On Mabinogi World Wiki, any number outputted by an expression, or this template, that exceeds 12 digits will be rounded off to the first 12 digits. For example,
- using this template: "{{User:ZRoc/trunc|12345678901234.567}}" will output "12345678901234".
- using an expression: "{{#expr:1234567.890129876}}" will output "1234567.8901299".
- Mabinogi World Wiki does not support the input of numbers as scientific notation (e.g., 8.567E-6) into expressions and doing so will result in an error message. This template uses expressions and therefore inputting numbers in scientific notation will result in an error message. Oddly enough, this wiki does allow numbers to be outputted in scientific notation (see below).
- On Mabinogi World Wiki, any large enough number outputted by an expression, or this template, will be given in scientific notation (and if it exceeds 12 digits then it will be rounded off to the first 12 digits). For example,
- using this template: "{{User:ZRoc/trunc|123456789012345678901234.123}}" will output "1.2345678901235E+23".
- using an expression: "{{#expr:-123456780000000000000000}}" will output "-1.2345678E+23".
- Code:
{{ #ifexpr: 1 > ( ( {{{1|0}}} ) * ( 1 - ( 2 * ( ( {{{1|0}}} ) < 0 ) ) )) <!-- ensures that --> and <!-- -0 is not a --> ( ( {{{1|0}}} ) * ( 1 - ( 2 * ( ( {{{1|0}}} ) < 0 ) ) )) >= 0 <!-- result --> | 0 | {{ #ifexpr: ( {{{1|0}}} ) * ( 1 - ( 2 * ( ( {{{1|0}}} ) < 0 ) ) ) < ( ( {{{1|0}}} ) round 0 ) * ( 1 - ( 2 * ( ( ( {{{1|0}}} ) round 0 ) < 0 ) ) ) | {{ #expr: ( ( {{{1|0}}} ) round 0 ) - ( ( 2 * ( ( ( {{{1|0}}} ) round 0 ) > 0 ) ) - 1 ) }} | {{ #expr: ( ( {{{1|0}}} ) round 0 ) }} }} }}