Allen bradley decimal to hex

S

Thread Starter

scott

I want convert decimal number to a hex number in a slc500. bcd format will not work. I need regular hex. Any ideas would be great.
 
A little more info would help, eg is it for display purposes, or what are you looking to do?
 
I'm not sure what you are asking. In any computer numbers exist in only in binary format. BCD (binary coded decimal) is just an irrational antiquated hangover from someones nightmare. The number display is converted to decimal or hex by the software displaying the number. As for binary to hex conversion it is pretty simple.
1111 1111 1111 1111 = FFFF. Each character of the four digit hex number represents four consecutive bits of a binary number or a value 0 to 15, hence base 16 or Hex. It makes a convenient notation method for binary. If you are wanting to convert to a string for output you will need to mask and shift bits and build your string on each four bit section. Unfortunately the SLC does not have an integer to string instruction with hex format although it does have an integer to string instruction with decimal format.
 
Top