Topic: DMD0536

Help File Version: 2.10.0.636

Math Negate Operator


The Math Negate operator ( - ) returns the same value with the opposite sign.

 

The operand can be any mix of signed integers, unsigned integers, real (floating point) numbers or discrete values. They can be any numeric or discrete memory location, or any numeric or discrete structure member.

 

All discrete values and all 16-bit integer values are promoted to 32-bit 2's complement signed integer values. If a Real value is included in the equation then all of the values will be promoted to Real values and all calculations will be performed using Real numbers.

 

Traditional math precedence rules are used to solve the math expression, The use of parentheses to remove any ambiguity in the processing order is encouraged.

 

assume D0 = 123456789 and D1 = -123456789 and R1 = 1234567.890 and X0 = ON

 

D0 = -D0

 

D0 = - (123456789)

D0 = -123456789

 

 

 

The operand is a signed integer memory location.

 

The result is placed in a signed integer memory location.

 

D0 = -D1

 

D0 = - (-123456789)

D0 = 123456789

 

The operand is a signed integer memory location.

 

The result is placed in a signed integer memory location.

 

R0 = -R1

 

R0 = - (1234567.890)

R0 = -1234567.890

 

The operand is a Real memory location.

 

The result is placed in a Real memory location.

 

C0 = -X0

 

C0 = - ( 0000_0000_0000_00001 )

C0 = 1111_1111_1111_1111

C0 = ON

 

The operand is a discrete memory location.

 

X0 is promoted to32-bit 2’s complement equivalent of 1. Negating it gives you -1, which in terms of a numeric compare, is still ON (non-zero).

 

The result is placed in a discrete memory location.

 

 


See Also:

Add

Subtract

Multiply

Divide

 

Modulus / Remainder

Raise to a Power

 

Less Than

Less than or Equal To

 

Equal To

Not Equal To

 

Greater Than

Greater Than or Equal To

 

Logical AND

Logical OR

 

Bit-wise AND

Bit-wise OR

Bit-wise XOR

 

Shift Left

Shift Right

Unsigned Shift Right

 

Negate

Bit-wise Invert

Logical NOT

 


Related Topics:

MATH - Calculate Expression