Yes, source B for the LES comparrison to check the sign of a number is 0.
In twos compliment 16 bit binary the only thing all negative numbers have in common is bit 15 is set. Likewise the only thing all positive numbers have in common is bit 15 is clear.
** This sole commonality means we can test the sign of any number by looking at bit 15. If we were testing any other conditons (such as all numbers less than 5 as you inquired in your PM to me) then there is no such commonality and a comparrison instruction is the best choice.
-------------------------------------
Continuing with twos complement numbers, do not think that you can change the sign of a number by just clearing or setting bit 15. (I assume you have looked at the link Ron provided.)
To illustrate this I will take just the case of the number -1 and 1.
1 is 0000000000000001
If I set bit fifteen then I would have 1000000000000001, which is
-32767.
-1 is 1111111111111111. If I clear bit 15 I will have 0111111111111111 which is 32767.
To change the sign you must multiply by -1 or use the NEG or ABS functions.
-------------------------------------
To see twos compliment in action, try this exercise out:
- Open RSLogix500 and create a new SLC5/05 project.
- Close the ladder file view. You wont need it.
- Double click on the file N7 in the project tree to open the data file view. You should see just N7:0. Drag the data file window over to where it is not covering the project tree.
- Now doulbe click on the R6 file. In the lower left corner of the R6 file you will see R6 in a small field. Click the up arrow next to that to increment the file to N7.
- Now you should have two windows showing the N7 data file.
- Change the radix of one of the data file windows to binary.
- Now you can set and clear individual bits in the binary radix view, every time you press the enter key after changing a bit in the binary view, the decimal value will update in the decimal radix view. Try different bit combinations with both bit 15 set and clear and see what you get.
(** we can also test a nummer to see if it is even or odd by looking at bit 0. If N7:0/0 is clear, the number is even. If N7:0/0 is set, the number is odd. This commonality holds for all even and odd numbers. I am not aware of any other cases of commonality)