# Negative Number Instead of Positive Number

• 01-01-2002, 07:03 PM
forskare
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
• 01-01-2002, 07:06 PM
Stan Mathews
RE: Negative Number Instead of Positive Number
Tell Alpha in what order to evaluate the expression.

(RETAIL_PRICE-CUST_PRICE)*QTY
• 01-01-2002, 07:09 PM
forskare
RE: Negative Number Instead of Positive Number
Of Course!!! Oh Dah!!!!

Thanks Stan,

kenn
• 01-02-2002, 09:28 AM
Tom Cone Jr
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