Skip to content
  • There are no suggestions because the search field is empty.

How to Read Signed Magnitude (16-bit)

Is it possible to use the TOP Server to interpret Signed Magnitude addressing?

The following table of values demonstrates the different expressions of 16 bit data, signed and unsigned.

Binary Value

Unsigned

Signed Two's Complement

Signed Magnitude

0000 0000 0000 0001

1

1

 1

1000 0000 0000 0001

32768

-32767

 -1

0000 0000 0001 0000

16

16

 16

1000 0000 0001 0000

32784

-32752

 -16


The TOP Server Advanced Tag Plug-in can be used to convert an unsigned word into a signed magnitude value by using the modulo operator. 

Formula

-(({InputTag}-{InputTag}%32768))/32768)*2-1)*({InputTag}%32768)

Example

-(((TAG (Data Type Examples.16 Bit Device.K Registers.Word1)-(TAG (Data Type Examples.16 Bit Device.K Registers.Word1)%32768))/32768)*2-1)*(TAG (Data Type Examples.16 Bit Device.K Registers.Word1)%32768)

3526 - SignedMagExample

The following screenshots demonstrate the operation on the input tag 'Word1' and the output from the Derived Tag through the OPC Quick Client application.

Negative Values

3526 - SignedMagNegValue

Positive Values

3526 - SignedMagPosValue