Truncate – PB Docs 2017

Truncate

PowerScript function

Description

Truncates a number to the specified number of decimal places.

Syntax

Argument

Description

x

The number you want to truncate.

n

The number of decimal places to which you want to truncate
x. Valid values are 0 through 28.

Return value

Decimal.

Returns the result of the truncation if it succeeds and null if it
fails or if any argument is null.

Using Truncate on a computed field

A real number loaded into a floating point register (used for
calculation) is represented as precisely as the binary storage will
permit. For example, the real number displayed as 2.07 is actually
stored as 2.06999999999999999999999997.

Truncating such a number may not give the expected result. To
avoid this problem, you can change the initial real datatype to long,
integer, or decimal, or you can append a constant in the truncate
argument: Truncate (x + 0.0000001, n )

Examples

This statement returns 9.2:

This statement returns 9.2:

This statement returns 9:

This statement returns -9.2:

See also

Ceiling

Init (obsolete)

Round

Truncate method for DataWindows in the section called “Truncate” in DataWindow Reference.


Document get from Powerbuilder help
Thank you for watching.
Was this article helpful?
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x