Why are BCD bits ordered 8-4-2-1 and not 1-2-4-8? - Page 1
Forum section: electronics / beginners

author: dentaku
author_rank: Frequent Contributor
timestamp: January 09, 2014, 11:50:41 pm
content: I'm wondering why BCD is organized the way it is.Why isn't the number one 1000 instead of 0001 and two is 0010 and not 0100 etc?In other words why are the bits ordered 8-4-2-1 and not 1-2-4-8?

author: AlfBaz
author_rank: Super Contributor
timestamp: January 09, 2014, 11:56:18 pm
content: probably the same reason the decimal number 192 is written as 192 rather than 291

author: c4757p
author_rank: Super Contributor
timestamp: January 09, 2014, 11:56:43 pm
content: Binary: 8 4 2 1Decimal: 1000 100 10 1

author: peter.mitchell
author_rank: Super Contributor
timestamp: January 10, 2014, 12:34:16 am
content: MSB/MSD comes first in most number systems...

author: idpromnut
author_rank: Unknown
timestamp: January 10, 2014, 12:42:04 am
content: Quote from: dentaku on January 09, 2014, 11:50:41 pmI suppose for the same reason that we order decimal numbers the same way: 1000s, 100s, 10s, 1: 8s, 4s, 2s, 1s in binary

author: Strada916
author_rank: Frequent Contributor
timestamp: January 10, 2014, 01:12:01 am
content: elementary my dear Watson elementary!as explained above.

author: TonyGreene
author_rank: Contributor
timestamp: January 10, 2014, 01:17:21 am
content: google Endianness and you will find it, it can go either way - depends on how the hardware is designed

author: Rigby
author_rank: Super Contributor
timestamp: January 10, 2014, 01:17:54 am
content: Well in computing it can go either way, and it often will, even within the same system.Intel CPUs as an example are "little endian" meaning that the bit with the lowest address is the least significant digit. So, in your example, this would be 1-2-4-8.ARM CPUs were big-endian (8-4-2-1) but as of version 3 they are now bi-endian, meaning that you can control the endianness via software configuration to suit your own needs. Very handy.When you design hardware that is implemented on an FPGA, it is very easy to swap endianness or to use little endian everywhere when you wanted big endian.In short, both types are used all over the freaking place in digital systems.

author: george graves
author_rank: Super Contributor
timestamp: January 10, 2014, 01:19:37 am
content: EDIT: Ah, I thought so.Doesn't that refer to little-endian vs big-endian? Or is that something different?

author: sleemanj
author_rank: Super Contributor
timestamp: January 10, 2014, 01:26:50 am
content: Quote from: dentaku on January 09, 2014, 11:50:41 pm0001 means we don't care about how many pointless bits before the first 1 there are, and we don't know how many bits wide the field is (only how many actually useful bits were given), this gives more efficient operations, consider a shift register with reset:To represent 1 as "1000" is RESET-Shift1-Shift0-Shift0-Shift0-LatchTo represent 1 as "0001" is RESET-Shift1-Latch(well, of course, that depends on how you take the data out of the register, but at least in my mind, it always goes "LSB" as the last shift).

author: dentaku
author_rank: Frequent Contributor
timestamp: January 10, 2014, 03:19:57 am
content: Great, I've heard about LSB and endian-ness all my life but It was probably the 90's since I ever paid attention to what it meant.I can see how it's like decimal numbers with the 1000's first then the 100's then the 10's then 1's when you have a 4 digit number.

author: digsys
author_rank: Unknown
timestamp: January 10, 2014, 03:33:16 am
content: Endianess refers to the BYTE order. The BITS in a byte remain MSB-LSB in all systems.

author: vk6zgo
author_rank: Super Contributor
timestamp: January 10, 2014, 04:54:18 am
content: Quote from: digsys on January 10, 2014, 03:33:16 amI always thought it referred to the state of being of an Existentialist Native American!

author: han
author_rank: Frequent Contributor
timestamp: January 10, 2014, 05:18:48 am
content: hi,yesterday my friend told me that he use BCD sequence like : 20-10-8-4-2-1 .i don't remember there any bigger number than 8 in BCD in the text book?could some body explanin? or even use it?or he just make a mistake...

author: digsys
author_rank: Unknown
timestamp: January 10, 2014, 05:32:20 am
content: Quote from: hanYup, probably a small glitch in his brain .. happens :-)

author: Dave
author_rank: Super Contributor
timestamp: January 10, 2014, 05:38:40 am
content: Quote from: han on January 10, 2014, 05:18:48 amThat's the tens digit.BCD is about coding decimal digits into binary code, hence the name (binary coded decimal). If you have a two digit decimal number, you need 8 BCD bits.

author: han
author_rank: Frequent Contributor
timestamp: January 10, 2014, 05:54:28 am
content: so the number will continuous to ..... 800-400-200-100-80-40-20-10-8-4-2-1 ?ow...i think not many people use the BCD . when i Google the two digit BCD , i haven't find any clue

author: sleemanj
author_rank: Super Contributor
timestamp: January 10, 2014, 06:30:37 am
content: Quote from: han on January 10, 2014, 05:18:48 amBCD is encoded with 4 bits typically, since there are only 10 decimal digits, that's all we need.BCD is simply taking each digit of a decimal number, encoding to binary, and there you go:0 = 00001 = 00012 = 0010...9 = 1001That's all you need. However some variations might further "characters", perhaps you want to add a decimal point, letters, some mathematical symbols, in which case another bit or two might be useful as an extension (if you need more than 6 extra characters anyway).The Max7219 7-segment driver for example provides some extra characters in its BCD decoding, although it just fits them into the 6 slots after 1001 without requiring a 5th bit.

author: sleemanj
author_rank: Super Contributor
timestamp: January 10, 2014, 06:35:28 am
content: Quote from: han on January 10, 2014, 05:54:28 amNot really no. Each digit is encoded as a bit sequence separately.Eg, the number 1345 is encoded to the 4 binary sequences0001001101000101(if those 4 digit binary numbers are packed into 2 bytes when sending or ... is not important for the discussion)The wikipedia article is a good place for you:http://en.wikipedia.org/wiki/Binary-coded_decimal#Basics

author: AlfBaz
author_rank: Super Contributor
timestamp: January 10, 2014, 08:07:56 am
content: There was that other one i cant think of its name right now, that was similar to bcd but altered so that only one bit changed on each increment

author: arcom
author_rank: Contributor
timestamp: January 10, 2014, 08:22:03 am
content: That's theGray Code. Used a lot with rotary encoders and similar devices.

author: Dave
author_rank: Super Contributor
timestamp: January 10, 2014, 08:33:55 am
content: Quote from: sleemanj on January 10, 2014, 06:35:28 amWell, you would in term split them, but they kind of are together when you convert them.Thisis how you convert a binary number into a set of BCD digits. As you can see, the result at the bottom is a long sequence of bits which you then in term split into fours.

author: amyk
author_rank: Super Contributor
timestamp: January 10, 2014, 10:40:31 am
content: Quote from: Rigby on January 10, 2014, 01:17:54 amDid you mean SPARC? ARM is little endian by default. SPARC started as big and became bi, ARM started as little and became bi.

author: woodchips
author_rank: Frequent Contributor
timestamp: January 10, 2014, 06:31:16 pm
content: Aren't modern computer engineers spoilt today!Wasn't it the TI 9900 that used bit 0 as the most significant bit. What a barmy idea that was, trying to concatenate words to make larger integers.Mind you, that was better than the computers that had bit 15 as a parity bit, so concatenating had to include shifting and masking, ughh!

author: SeanB
author_rank: Super Contributor
timestamp: January 10, 2014, 06:43:40 pm
content: Or processors that have a binary and a decimal mode, and if you leave it in decimal mode you get some really weird problems on things like conditional branches and carries.