Connection Information

To perform the requested action, WordPress needs to access your web server. Please enter your FTP credentials to proceed. If you do not remember your credentials, you should contact your web host.

Connection Type

Arithmetic operators in PowerBuilder – PB Docs 150 – PowerBuilder Library

Arithmetic operators in PowerBuilder – PB Docs 150

Arithmetic operators in PowerBuilder

Description

The following table lists the arithmetic operators used in
PowerBuilder.

Table 4-1: PowerBuilder arithmetic operators

Operator

Meaning

Example

+

Addition

Total=SubTotal+Tax

Subtraction

Price=Price–Discount

Unless you have prohibited the use of dashes in identifier
names, you must surround the minus sign with spaces.

*

Multiplication

Total=Quantity*Price

/

Division

Factor=Discount/Price

^

Exponentiation

Rank=Rating^2.5

Usage

Operator shortcuts for assignments

For information about shortcuts that combine arithmetic operators
with assignments (such as ++ and +=),
see Assignment.

Subtraction

If the option Allow Dashes in Identifiers is checked on the Script
tab in the Options dialog box, you must always surround the subtraction operator
and the operator with spaces. Otherwise, PowerBuilder
interprets the expression as an identifier.

For information about dashes in identifiers,
see “Identifier names”.

Multiplication and division

Multiplication and division are carried out to full precision
(16–28 digits). Decimal numbers are rounded (not truncated)
on assignment.

Calculation with NULL

When you form an arithmetic expression that contains a NULL value,
the expression’s value is null. Thinking
of null as undefined makes
this easier to understand.

For more information about null values,
see “NULL values”.

Errors and overflows

The following problems can occur when using arithmetic operators:

  • Division by zero, exponentiation of negative values,
    and so on cause errors at runtime.

  • Overflow of real, double, and decimal values causes
    errors at runtime.

  • Overflow of signed or unsigned integers and longs
    causes results to wrap. However, because integers are promoted to
    longs in calculations, wrapping does not occur until the result
    is explicitly assigned to an integer variable.

    For more information about type promotion,
    see “Datatype of PowerBuilder
    expressions”
    .

Examples

Subtraction

This statement always means subtract B from A:

If DashesInIdentifiers is set to 1, the following statement
means a variable named A-B, but if DashesInIdentifiers is set to
0, it means subtract B from A:

Precision for division

These examples show the values that result from various operations
on decimal values:

Calculations with null

When the value of variable c is null,
the following assignment statements all set the variable a to null:

Overflow

This example illustrates the value of the variable i after
overflow occurs:


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