Trunc: Difference between revisions
m (1 revision: Krakiipedia Import) |
(how to use the wiki expression parser) |
||
(4 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
''' |
'''Truncation''' or '''trunc''' is a mathematical term that appears frequently in [[GemStone IV]] equations that do everything from figuring out a character's [[mana point]] total to how many [[premium point]]s it costs to [[enchant]] an item. |
||
To truncate a number, remove all decimal places after the whole number (integer) without rounding. Thus, 6.1 and 6.9 would both be 6 when truncated. |
|||
⚫ | |||
<div {{prettydiv}}>Enchanting plain item (+5 added) with a starting enchant bonus of +16 to +45<br>1200 + (400 * trunc((current plus - 11) / 5)))= Total premium points required</div><br> |
|||
⚫ | |||
⚫ | |||
Total premium points required for enchanting plain item (+5 added) with a starting enchant bonus of +16 to +45: |
|||
:{{math|1200 + (400 * trunc((current plus - 11) / 5)))}} |
|||
For this example we'll use a "current plus" of 20 (the item is standard 4x enchanted). |
|||
⚫ | |||
== "Trunc to 0.xx" == |
|||
In some formulas, instead of truncating to a whole number, values may be truncated to {{math|''n''}} digits after the decimal point. In mathematical terms this is the {{math|trunc(''x'', ''n'')}} function. On the wiki this may also be described as "{{math|trunc to 0.XX}}" for 2 digits, etc. |
|||
== Wiki Expressions == |
|||
GSWiki supports inline expression parsing using <code>trunc</code>. |
|||
*<code><nowiki>{{#expr: trunc(1.234)}}</nowiki></code> produces {{#expr: trunc(1.234)}} |
|||
*<code><nowiki>{{#expr: trunc(1.234 * 100) / 100}}</nowiki></code> produces {{#expr: trunc(1.234 * 100) / 100}} |
|||
== References == |
|||
*[https://en.wikipedia.org/wiki/Truncation Truncation] on Wikipedia |
|||
[[category:Real Life]] |
[[category:Real Life]] |
Latest revision as of 15:50, 31 May 2018
Truncation or trunc is a mathematical term that appears frequently in GemStone IV equations that do everything from figuring out a character's mana point total to how many premium points it costs to enchant an item.
To truncate a number, remove all decimal places after the whole number (integer) without rounding. Thus, 6.1 and 6.9 would both be 6 when truncated.
Example
Total premium points required for enchanting plain item (+5 added) with a starting enchant bonus of +16 to +45:
- 1200 + (400 * trunc((current plus - 11) / 5)))
For this example we'll use a "current plus" of 20 (the item is standard 4x enchanted).
- 1200 + (400 * trunc((20 - 11) / 5))) = 1200 + (400 * trunc(9/5)) = 1200 + (400 * trunc(1.8)) = 1200 + (400 * 1) = 1200 + 400 = 1600
"Trunc to 0.xx"
In some formulas, instead of truncating to a whole number, values may be truncated to n digits after the decimal point. In mathematical terms this is the trunc(x, n) function. On the wiki this may also be described as "trunc to 0.XX" for 2 digits, etc.
Wiki Expressions
GSWiki supports inline expression parsing using trunc
.
{{#expr: trunc(1.234)}}
produces 1{{#expr: trunc(1.234 * 100) / 100}}
produces 1.23
References
- Truncation on Wikipedia