 1. ## Negative Number Instead of Positive Number

I have the following expression in a calculated field in the table's Field rules):

RETAIL_PRICE-CUST_PRICE*QTY

It returns a negative number. For instance; 18.45-14.76*3 = -25.83 instead of 11.07
What do I need to change?

Thanks,

kenn  Reply With Quote

2. ## RE: Negative Number Instead of Positive Number

Tell Alpha in what order to evaluate the expression.

(RETAIL_PRICE-CUST_PRICE)*QTY  Reply With Quote

3. ## RE: Negative Number Instead of Positive Number

Of Course!!! Oh Dah!!!!

Thanks Stan,

kenn  Reply With Quote

4. ## RE: Negative Number Instead of Positive Number

For any who may be 'looking in' on this thread,

Ken's original expression gave the wrong number because the multiplication operation takes precedence over the subtraction. The expression is not evaluated from left to right. It's evaluated in order by arithmetic operator precedence.

This is explained in the User's Guide at p 207 in the discussion of 'Arithmetic Operator Precedence'.

Interestingly, the example give in the book says:

3 + 4 * 5 is equivalent to 3 + (4 * 5) since the multiplication operation takes precedence over the addition operator.

-- tom  Reply With Quote

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•