### Truncate (x), Truncate (x, #places)

Truncate and Fix are equivalent functions. However, Truncate is preferred in Crystal syntax whereas Fix is preferred in Basic syntax.

##### Arguments

- x is a fractional Number to be truncated.
- #places is a whole number indicating how many decimal places are to remain after the value is truncated. (This argument is optional.)

##### Returns

Fractional Number

##### Action

Truncate(x) returns a whole number by truncating the number at the decimal point. If the #places argument is specified, the number is truncated to the decimal place indicated and the function returns a fractional Number. If #places is negative, the number is rounded to the first ten, hundred, and so on.

##### Typical uses

Use this function whenever the characters to the right of the decimal are not needed for a report or calculation.

##### Examples

The following examples are applicable to both Basic and Crystal syntax, although Fix is preferred in the latter:

`Truncate(1.23456)`

Returns 1.

`Truncate(1.499)`

Returns 1.

`Truncate(1.599)`

Returns 1.

`Truncate(1.999)`

Returns 1.

`Truncate(12346.33, 1)`

Returns 12346.3.

`Truncate(12345.33, -2)`

Returns 12300.00.

If you have 147 golf balls in stock and want to know how many dozen are available for sale, your calculation is 147/12=12.25 12.25 (truncated) = 12 dozen available for sale. If you sell balls only by the dozen, the .25 dozen you truncated is unimportant.

`Truncate({file.BALL INVENTORY} / 12)`

Returns 12 where Ball inventory = 147 (147 / 12 = 12.25, 12.25 truncated = 12).

`Truncate({file.BALL INVENTORY} / 12)`

Returns 12 where Ball inventory = 155 (155/12 = 12.92, 12.92 truncated = 12).

`Truncate({file.BALL INVENTORY} / 12)`

Returns 13 where Ball inventory = 157 (157/12 = 13.08, 13.08 truncated = 13).

##### Comments

- This is not a rounding function; Truncate simply deletes all characters to the right of the decimal point.

  See the Round (x), Round (x, #places) for an explanation on rounding.

- Truncate (n) and Int (number) are synonymous except when n (number) is negative, in which case Truncate returns the first integer greater than or equal to n, and Int returns the first integer smaller than or equal to n. For example,

`Truncate (-10.2)`

Returns -10.

`Int (-10.2)`

Returns -11.

- Truncating is also a feature available as a formatting option for numerical values in fields. Be aware that using field formatting features may affect how values are used in formulas. For more information on converting to Numbers and Currency, see the ToNumber (numeric), ToNumber (string) and To currency operator.

###### Related topics

Int (number)

Formula 13

Seagate Software, Inc. http://www.seagatesoftware.com Please send comments to: techpubs@seagatesoftware.com