Decimal to integer

Type conversion Pure
Decimal to integer
Value 0
Result

Description

Pure function converting a decimal to an integer, truncating toward zero.

When to use

Use Decimal to integer when you need the integer part of a decimal value — for example, after dividing a total by a rate to get a whole-number count. Truncation is toward zero (not floor), so -3.9 becomes -3. If you need floor or round behaviour, apply the appropriate arithmetic before converting. For widening in the other direction (integer to decimal), use Integer to decimal.

Pins

Input pins

Pin Type Default Notes
Value decimal 0 The decimal to truncate. Values like 3.9 become 3; -3.9 becomes -3 (truncation toward zero, not floor).

Output pins

Pin Type Notes
Result integer The integer part of the decimal, with the fractional part discarded.

Example

Compute the number of full weeks from a total number of days. Wire the day count through Integer to decimal, then divide by 7.0. Feed the decimal quotient into the Value input of Decimal to integer — dividing 17 days by 7.0 produces 2.428…, which truncates to 2, the number of complete weeks. Convert the Result output with Integer to string before logging.

See also