PreviousNextIndex

TRUNCATE function

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

Syntax

TRUNCATE ( expression , decimal-places ) 

expression
decimal-places
Example

This procedure doubles each Customer’s CreditLimit and then truncates that value before rounding it to the nearest $1000:

r-trunc.p
FOR EACH Customer: 
  FORM Customer.CustNum Customer.Name Customer.CreditLimit 
    new-max LIKE Customer.CreditLimit LABEL "New Credit limit". 
  DISPLAY Customer.CustNum Customer.Name Customer.CreditLimit. 
  Customer.CreditLimit =  
    TRUNCATE((Customer.CreditLimit * 2) / 1000 ,0) * 1000. 
  IF Customer.CreditLimit < 15000 THEN  
    Customer.CreditLimit = 15000. 
  DISPLAY Customer.CreditLimit @ 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


OpenEdge Release 10.2B
Copyright © 2009 Progress Software Corporation
PreviousNextIndex