# Trunc

Jump to: navigation, search

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