1H Numbering Systems

InThisAppendix.... — Introduction — Binary Numbering System — Numbering System — Octal Numbering System — Binary Coded Decimal (BCD) Numbering System — Real (Floating Point) Numbering System — BCD/Binary/Decimal/Hex/Octal -- What is the Difference? —DataTypeMismatch — Signed vs. Unsigned Integers — AutomationDirect.com Products and Data Types Appendix H H--2 Numbering Systems L0 srMna,4hEiin e.A Rev. Edition, 4th Manual, User DL405 iayNmeigSystem Numbering Binary Introduction ubrn Systems Numbering ifrn ae ilb hw sasbcitdnme olwn h number. the following number 10 base subscripted the a using 10 as up be the on, would shown grown now decimal have From be 10 aware. we well Example: will all since are we bases use as 0--9, to different numbers the us uses 10 for Base “natural“ system. not is Binary yeo 11010101 of 64 iso w od sadul oda nTbe1. Table in Thirty--two as in. word as word double a a be is would two words or two two or Eight or bits nibble. bits Sixteen a byte. as When known a . is be a what called would form is nibbles computer they together, a grouped by are referenced when bits system four 2 but base values, the digits. possible in be several two digit would using Each only it with encoding that 2 by think Base is on would secret You built respectively. PLC system the a on called numbering 2 and a Base is have off in to or which digits hard valid one, system, two and only zero numbering are there on, 2 computer relies a Base in Like the Boolean. or use Binary PLCs, including Computers, PLC the specifically system binary systems the numbering PLC. the a of of by aware explanation used commonly an more most provide will be appendix should This programmer. user PLC nature underlying actually A the of is with aspect system. confronted what this gets binary about to one think the to then closer of need and no are now has (1) yes” every user ”one” PC but and and typical computers, a (0) ”no” time ”zero” the sometimes for of or Most digits possible involved. the ”on” two by and the represented Traditionally, ”off” are system. although system number binary binary a a for with states of done operations actual are the aware, computer somewhat is a computer a uses who anyone almost As al hw o ae2nmesrlt oterdcmlequivalents. decimal their to 1001 of relate nibble numbers A 2 base how shows 2 Table 0 Nibble 10 0 +16 0 Byte 0 10 0 +4 Nibble 0 10 0 2 +1 2 ol eeult eia ubr9(1*2 9 number decimal a to equal be would Word 0 ol eeult 1 (1*2 213 to equal be would 10 0 ). Nibble 0 0 Byte 0 0 Nibble obeWord Double 0 10 . 0 al 2 Table 1 Table 0 0 Nibble 0 7 0 +1*2 Byte 0 0 6 Nibble +1*2 0 0 4 Word 0 +1*2 3 +1*2 0 Nibble 0 2 +1*2 0 0 r8 or Byte 0 0 10 0 r128 or Nibble +1 0 10 0 10 .A ). 0 + Appendix H Numbering Systems H--3 9 F B E A D 11 10 Hex Numbering Systems 9 11 12 13 14 15 16 17 10 Decimal 6x16 + 5 = 869. To avoid confusion, hex DL405 User Manual, 4th Edition, Rev. A 2 2 3 4 5 6 7 8 0 1 Hex Table 3 l + 6x10 + 5. In hex each digit represents a multiple 2 + 10x16 + 15 = 55471. However, going through the 2 3 4 5 6 7 8 0 1 2 Decima +8x16 3 arithmetic for hex numberseasier in way order is to to evaluate useconvert the between them decimal is that and not comes hex really as when necessary. an inNote The accessory that “Scientific“ a in view. hex Windows. number It suchIts can as actual “365“ value is not in the decimal same terms as the is decimal 3x16 number “365“. The binary numbering system can beusers. difficult and cumbersome to Therefore, interpret forconvenience some the for humans hexadecimal sinceThe the hexadecimal system PLC numbering is (computer) useful because only it systemconsecutive can understands hexadecimal represent every digits. pure byte It was (8 is binary. bits) easier as forbinary two us developed to numbers. read hexadecimal numbers as than a The hexadecimal numberingvalues. system The uses first ten 16 charactersfirst characters six are letters the (base of same the 16) as alphabet,0--17 in Table A--F. to our 3 the lists decimal represent left the system, first column 0--9,right eighteen and and decimal column. the the numbers; equivalent hexadecimal numbers are shown in the numbers are often labeled ortagging tagged hex so numbers that is theirlabeling to meaning is append is to precede a clear. the One lower number methodwritten with case 0x. “D8AFh“, of “h“ Thus, where the at the hex the lower numberknow case “D8AF“ end. can “h” that Another also at be method it the of end is“0xD8AF”. is a just a hex label number. to Also, make sure D8AF we can be written with a labeling prefix as of a powerdecimal of means sixteen 13x16 (base 16). Therefore, the hex number D8AF translated to Note that “10” and “11“ infirst hex are ten not the numbers sameconsider as the “10“ hex 0--9 number and “D8AF“. are “11“ Toevaluate in this decimal.used the hex to Only number write the use decimal same the numbers. same Each method in digitof in a a power the decimal of number ten represents (base two 10). adecimal Powers multiple number of representations. 365 ten means increase from 3x10 For right to left. example, For example, the Hexadecimal Numbering System Appendix H H--4 Numbering Systems L0 srMna,4hEiin e.A Rev. Edition, 4th Manual, User DL405 ca ubrn System Numbering Octal ubrn Systems Numbering hsflosthe follows This hr d en ii.Ti stesm omtue ntebnr,dcml or decimal, binary, the in 8. used is octal format for same number base the the is that This except systems digit. hexadecimal means “d“ where htteotlvle r -7 0-7 0-7 n 30--37. Note The octal. and 20--27, numbers. in 10--17, digits 0--7, compiled represent decimal are 32 to first for values the numbering octal values shows system Octal the 4 8 Table that the 8. numbering uses uses Base being system that 0--7 octal are device numbering values the only octal the used The about system. is computers PLC early the Today, printouts. the of Many h eea omtfrfu iiso h ca ubris: number octal the of digits four being for octal 9 format The and general 8 bit. The digits each the as without system well decimal as the in octal, available. counting in like numbered much is are system addresses memory the that Direct (dx8 Octal OI Ls ee otebtmp nCatr3adnotice and 3 Chapter in maps bit the to Refer PLCs. LOGIC 17 16 15 14 13 12 10 11 6 5 4 3 2 1 0 7 0 )+(dx8 Decimal 15 14 13 12 10 11 1 6 5 4 3 2 1 0 9 8 7 )+(dx8 al 4 Table Octal 2 26 25 24 23 22 21 20 37 36 35 34 33 32 31 30 27 )+(dx8 Decimal 3 ) 22 21 20 19 18 17 16 31 30 29 28 27 26 25 24 23 Appendix H Numbering Systems 0 1 H--5 1 2 0 9 10 2 4 3 8 4 1 5 2 1 9 10 6 4 Numbering Systems 7 8 8 1 DL405 User Manual, 4th Edition, Rev. A 9 2 2 9 Table 5 10 4 10 BCD Bit Pattern 8 11 1 12 2 13 3 9 10 4 14 8 15 Bit # Power Bit Value BCD is a numbering system where fourThe bits are binary used codes to represent corresponding each to decimalBCD digit. system. the For hexadecimal this digits reason numbers A--Fsystem. are cannot For be not example, coded a used as byte in efficiently can represent using the 0--255) a the using maximum BCD normal of binary, 256 whereas different only numbers (i.e. 100coded distinct using numbers BCD. (i.e. Also, 0--99) could note be does that negative BCD numbers. is a subset of hexadecimal and neither one Using the powers of expansion,decimal. the example below shows octal 4730 converted to One plus for BCD ismean that it 867 reads decimal. like No a conversion decimal number, is whereas needed. 867 in BCD would Max Value Binary Coded Decimal (BCD) Numbering System Appendix H H--6 Numbering Systems L0 srMna,4hEiin e.A Rev. Edition, 4th Manual, User DL405 el(laigPit ubrn System Numbering Point) (Floating Real ubrn Systems Numbering h nentcnpoieamr n-et xlnto ftefotn point floating the of explanation in--depth is: more at look a to website provide One system. can numbering Internet The summary: In bits. fraction the are (22--0) (30--23) bits bits eight 23 next the final bit, the number sign the and a is bits as (31) bit represented exponent first is the The IEEE right. It are the to 6. left for Table 31, to required in 0 shown from word bits is bit numbers 32 point The floating mantissa. standard which and exponent numbers, sign, components: point Floating are u nte.Ms Lsuete3-btfra o laigpit(rReal) (or point floating for format be 32--bit should here. the discussed arithmetic use be how will PLCs as which Most bit) well numbers (64 as them. precision represented on double be out and to carried bit) are (32 numbers precision point single floating how specifies arithmetic. point standard floating IEEE--754 This describe both floating--point and Real terms The i # Bit # Bit h is i ftemnis stpclyasmdt e“.f“ hr f stefedof field the is “f“ where “1.fff“, be to assumed bits. typically fraction is mantissa the of bit negative; first The for 2; “1“ base or uses positive exponent for The “0” either is bit sign The Sign http://www.psc.edu/general/software/packages/ieee/ieee.php 15 31 14 30 13 29 el(laigPit3)BtPattern Bit 32) Point (Floating Real 12 28 Exponent atsa(otne rmabove) from (continues Mantissa 27 11 10 26 Direct 25 9 al 6 Table 24 8 OI Lsue aetrebasic three have use, PLCs LOGIC 23 7 22 6 21 5 20 4 Mantissa 19 3 18 2 17 1 16 0 Appendix H Numbering Systems 0 1 0 0 1 0 1 0 1 16 H--7 7 1 2 1 1 2 1 2 1 2 17 9 F 2 4 2 4 2 4 2 2 4 18 3 8 3 8 3 1 3 3 8 19 Mantissa 7 4 1 4 1 4 2 4 4 1 6 20 Numbering Systems 5 2 5 2 5 4 5 5 2 3 21 9 F 6 4 6 4 6 1 6 6 6 4 22 DL405 User Manual, 4th Edition, Rev. A 7 7 8 8 7 2 7 7 2 8 7 1 23 Table 7 65535 8 1 8 1 8 4 8 8 2 5 6 24 9 2 9 2 9 1 9 9 5 1 2 25 9 F BCD Bit Pattern Octal Bit Pattern Octal Bit Pattern 7 4 4 2 1 0 2 4 10 10 10 26 10 10 Mantissa (continued from above) Hexidecimal Bit Pattern Binary/Decimal Bit Pattern 8 4 2 0 4 8 8 27 11 11 11 11 11 Exponent 1 1 4 0 9 6 1 28 12 12 12 12 12 7 LOGIC PLCs. The PLC’s native data format is BCD, while the I/O numbering 2 2 8 1 9 2 2 29 13 13 13 13 13 F 9 4 4 1 6 3 8 4 4 30 14 14 14 14 14 Sometimes there is confusion about theDirect differences between the data typessystem used in is octal.Although data Other is stored in numbering the sameway formats manner that (0’s and the used 1’s), PLC there are are interprets differences inWhile it. the binary, all of decimal the formats rely andformat in of the Real. base the 2 data numbering is system and dissimilar. bit--coded The data, formats the discussed are shown in Table 7 below. As seen inmaximum Table number 7, for the each grouping BCDThis is different and allows (9 hexadecimal for both BCD formatseffect formats and is F are to for that similar, hexadecimal). unless use although thetype the data the is type same unless is display documented, it it’s contains method. difficult the The to letters know unfortunate A--F. what side the data 8 1 1 3 2 6 7 8 8 31 15 15 15 15 15 Sign Bit # Bit # Bit Value Max Value Bit # Bit # Decimal Bit Value Max Value Bit # Decimal Bit Value Max Value Bit Value Max Value Bit # Decimal BCD/Binary/Decimal/Hex/Octal -- What is the Difference? Appendix H H--8 Numbering Systems L0 srMna,4hEiin e.A Rev. Edition, 4th Manual, User DL405 aaTp Mismatch Type Data Binary BCD Decimal ubrn Systems Numbering 0000 0000 0 0001 0001 1 tal u ol erpeetdi eaeia s0xFFF. value BCD as valid hexadecimal a in not is represented a it be value, as BCD could interpreted a but you as is if pattern all, Similarly, pattern bit 1653310. at (binary) bit of decimal value BCD the 10 the view base a to if is try result instance, bit the For pattern, If bit correct. them, 409510. (binary) write be bit decimal to of used not BCD value is the what will 10 than both data base format different the a a 9, in to Table interpreted, correspond or in read, pattern are shown patterns bit value decimal the the as and such pattern number, larger a at the BCD the Looking the numbers, causing for larger invalid binary, With actually in are BCD. Decimal 16 the type. 15 bit as of to data BCD 10 it value from viewing The values a when Binary changes. to multiplies. by error pattern equal digits six bit actually jump is the to 10 10, number decimal past the the to get get for you you until pattern up Once pattern bit 10. same number the share decimal binary and BCD shows, table the As ubrn ytm.Tedcmlvle f6 n 60aeused. are 4660 and 67 of values different the decimal by represented The value systems. same the numbering note and examples following the at Look iay(ninditgr omt hsi ret oeetn,btnti hscase. this in not differ. but numbers extent, binary some and to BCD PLC with how true interchangeable the shows is is Since it 8 This Table think symptoms. format. to the tend interface. integer) people identify (unsigned operator many you binary format, an until native using the challenge as when BCD a uses problem be common can a it Diagnosing is mismatching type Data 0010 0010 2 1001 iay00 0001 10Binary BCD 0100 0011 0000 0010 0110 0001 0110 0100 Binary 0011 BCD 0100 0111 0110 103Octal 11064Octal ae1 Value 10 Base 3 e 1234Hex43Hex 67Decimal 4660Decimal 0011 0011 3 4095 0100 0100 aaTp Mismatch Type Data 4 0101 0101 5 1000 010101 1001 0000 0100 0110 0110 C i Pattern Bit BCD 6 0111 0111 al 8 Table al 9 Table 7 1000 1000 8 1001 1001 9 iayBtPattern Bit Binary 001010 0000 0000 0001 1111 1111 1111 1111 10 010001 0001 001011 0000 11 Appendix H Numbering Systems H--9 0 1 2 3 4 5 Numbering Systems 6 1001 1100 7 Thus, a 16 bit word allows numbers in Binary Binary DL405 User Manual, 4th Edition, Rev. A 8 9 Table 11 Table 12 Table 10 1111 1111 0000 0000 0110 0100 1000 0000 0110 0100 0000 0000 0110 0100 10 Two’s Compliment Magnitude Plus Sign 11 added. 12 100 100 --100 --100 da0apositivenumber. Decimal Decimal 13 na1is 14 32767. The following tables show a representation of 100 and a 15 ¦ # http://www.website.masmforum.com/tutorials/fptute/fpuchap2.htm http://www.evergreen.edu/biophysics/technotes/program/2s_comp.htm Bit representation of --100 in this format. So far, we have dealtdata types with (negative unsigned numbers). data Thenot types BCD use only. and Now signed hexadecimal we data numbering will systems types. do dealIn with order signed to signifyUsually, that this a is number the isnumber, Most this negative is or Significant bit 15. positive, Bit This means we (MSB) thatto for must as 32767. 16--bit numbers assign we shown have a a in range bit of Table to --32767 10. it. For a 16--bit Two’s complement is aexplanation, bit a simple more formula complicated. forone Without two’s (see getting complement Table is involved 12). tochanged with Basically, invert to a 1’s the 1, full binary are the and being add changed to 0’s and all 0’s are being More information about 2’s complement canof be found the on websites the deal Internet, with however 8--bityou most examples. can Two fairly also good do websites are a listed search below, and checkout more websites. There are two ways to encode aPlus negative number: sign. two’s complement The and Magnitude two methods areThe not simplest compatible. method toword represent as a the sign negative of number ais is number general while to convention the use remainder to of oneindicate use the a bit word negative, the an of gives most its the significant magnitude. PLC It bit (MSB) as the sign bit: a 1 will the range Signed vs. Unsigned Integers Appendix H H--10 Numbering Systems L0 srMna,4hEiin e.A Rev. Edition, 4th Manual, User DL405 Panels Micro--Graphic C--more/C--more Types Data and Products AutomationDirect.com Direct OI PLCs LOGIC ubrn Systems Numbering bnr)fra ri C omt oi sncsayt nwhwtemdl sbeing is module the how know to necessary is it so used. format, BCD in or format (binary) hnuigteDt iwin View Data the using When can This complement. loop. two’s PID a use debugging functions while math confusion standard cause the whereas numbers, NOTE: IBox Math Most the in 30, are page Supplement, Instructions Manual group. User (IBox) PLC Instructions Box IBox DL405 Intelligent conversions with number available making, be will simplify operation (binary) math To decimal any of a results to the added mismatched, be are meaningless. cannot types number data instructions, BCD the a Math If and number. number, using real When a box. to number, added instruction real match BTOR a to must a BCD to types and from BCD change BIN from To value box. a a instruction change use BIN to a example, of use For limitations (binary), so. the of decimal doing aware when be types but another, data to various the type the cases, data one many from Math In changed instructions, be etc. can Load instructions, data comparison includes: use instructions, which must some box data type from Out of data comes instructions, manipulation that or Any programmer, for interface. the appropriate operator by instructions an changed as is such it source, if be external counter types may and locations data V--memory in timer other data including in User counters, default. PLC, stored by the format timers, BCD in in data locations, is values, Most V--memory current etc. (bits), internal relays control outputs, internal inputs, includes: which The eryalo h I aaeesaesoe ntePCmmr sdcml(binary) decimal as memory PLC the in stored are parameters numbers. PID the of all nearly oeaalbefrasae BDit3“ Usge n 2 n Sge n 32“. int “Signed and 32“ int “Unsigned 32“, int “BCD are, formats format number available Real More “Signed negative. or be 16“ can 32”. int value PT the “Unsigned “Floating not either is or is whether BCD format on 16--bit Binary depending the 16“. 16“ int panels, int “BCD operator as HMI listed Micro--Graphic is C--more format and crucial. C--more is the memory documentation In in good stored where is display type This a data different. share the be they may of so values hexadecimal the called of though is subset even BCD a that format is notice Also BCD window. that the View using Remember Data selected BCD/Hex. the is of length top and the type data at The boxes drop--down viewed. be to element the for selected Direct Direct Direct h I loih ssmgiuepu infrngtv eia (binary) decimal negative for sign plus magnitude uses algorithm PID The OI L aiyue h ca ubrn ytmfraladdressing all for system numbering octal the uses family PLC LOGIC LOGIC LOGIC Direct o xml,aBDo eia bnr)nme antbe cannot number (binary) decimal or BCD a example, For . analog PID OT5 hs ntuto ecitosaelctdi the in located are descriptions instruction These 5. SOFT saohrae hr o l ausaei C.I fact, In BCD. in are values all not where area another is oue a estpt ieterwdt ndecimal in data raw the give to setup be can modules Direct OT ecranta h rprfra is format proper the that certain be SOFT, h data the