Progress
Language Reference


TRUNCATE Function

Interfaces
OS
SpeedScript
All
All
Yes

Truncates a decimal expression to a specified number of decimal places, returning a decimal value.

SYNTAX

TRUNCATE ( expression , decimal-places ) 

expression

A decimal expression that you want to truncate.

decimal-places

A non-negative integer expression that indicates the number of decimal places for a truncated expression.

EXAMPLE

This procedure doubles each customer’s credit-limit and then truncates that value before rounding it to the nearest $1000.

r-trunc.p
FOR EACH customer:
  FORM cust-num name credit-limit
    new-max LIKE credit-limit LABEL "New Credit limit".
  DISPLAY cust-num name credit-limit.
  credit-limit = TRUNCATE( (credit-limit * 2) / 1000 ,0) * 1000.
  IF credit-limit < 15000 THEN credit-limit = 15000.
  DISPLAY credit-limit @ new-max.
END. 

NOTE

You can use the TRUNCATE function to treat division as integer division; for example, i = TRUNCATE (x / y, 0).

SEE ALSO

ROUND Function


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095