Author Topic: Why are BCD bits ordered 8-4-2-1 and not 1-2-4-8?  (Read 6549 times)

0 Members and 1 Guest are viewing this topic.

Offline dentaku

  • Frequent Contributor
  • **
  • Posts: 849
  • Country: ca
Why are BCD bits ordered 8-4-2-1 and not 1-2-4-8?
« on: January 09, 2014, 11:50:41 pm »
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?
 

Online AlfBaz

  • Super Contributor
  • ***
  • Posts: 2030
  • Country: au
Re: Why are BCD bits ordered 8-4-2-1 and not 1-2-4-8?
« Reply #1 on: January 09, 2014, 11:56:18 pm »
probably the same reason the decimal number 192 is written as 192 rather than 291
 

Offline c4757p

  • Super Contributor
  • ***
  • Posts: 7805
  • Country: us
  • adieu
Re: Why are BCD bits ordered 8-4-2-1 and not 1-2-4-8?
« Reply #2 on: January 09, 2014, 11:56:43 pm »
Binary: 8 4 2 1
Decimal: 1000 100 10 1
No longer active here - try the IRC channel if you just can't be without me :)
 

Offline peter.mitchell

  • Super Contributor
  • ***
  • Posts: 1568
  • Country: au
Re: Why are BCD bits ordered 8-4-2-1 and not 1-2-4-8?
« Reply #3 on: January 10, 2014, 12:34:16 am »
MSB/MSD comes first in most number systems...
 

Offline idpromnut

  • Supporter
  • ****
  • Posts: 613
  • Country: ca
Re: Why are BCD bits ordered 8-4-2-1 and not 1-2-4-8?
« Reply #4 on: January 10, 2014, 12:42:04 am »
Why isn't the number one 1000 instead of 0001 and two is 0010 and not 0100 etc?

I suppose for the same reason that we order decimal numbers the same way:  1000s, 100s, 10s, 1:   8s, 4s, 2s, 1s in binary
 

Offline Strada916

  • Frequent Contributor
  • **
  • Posts: 252
  • Country: au
Re: Why are BCD bits ordered 8-4-2-1 and not 1-2-4-8?
« Reply #5 on: January 10, 2014, 01:12:01 am »
elementary my dear Watson elementary!  :-/O

as explained above.
The Bone, the Off-White, the Ivory or the Beige?
 

Offline TonyGreene

  • Contributor
  • Posts: 11
Re: Why are BCD bits ordered 8-4-2-1 and not 1-2-4-8?
« Reply #6 on: January 10, 2014, 01:17:21 am »
google Endianness and you will find it, it can go either way - depends on how the hardware is designed
 

Offline Rigby

  • Super Contributor
  • ***
  • Posts: 1476
  • Country: us
  • Learning, very new at this. Righteous Asshole, too
Re: Why are BCD bits ordered 8-4-2-1 and not 1-2-4-8?
« Reply #7 on: January 10, 2014, 01:17:54 am »
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.
 

Offline george graves

  • Super Contributor
  • ***
  • Posts: 1259
  • Country: us
Re: Why are BCD bits ordered 8-4-2-1 and not 1-2-4-8?
« Reply #8 on: January 10, 2014, 01:19:37 am »
EDIT:  Ah, I thought so.

Doesn't that refer to little-endian vs big-endian? Or is that something different?

Offline sleemanj

  • Super Contributor
  • ***
  • Posts: 2493
  • Country: nz
  • Professional tightwad.
    • The electronics hobby components I sell.
Re: Why are BCD bits ordered 8-4-2-1 and not 1-2-4-8?
« Reply #9 on: January 10, 2014, 01:26:50 am »
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?

0001 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-Latch
To 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).
« Last Edit: January 10, 2014, 01:29:10 am by sleemanj »
~~~
EEVBlog Members - get yourself 10% discount off all my electronic components for sale just use the Buy Direct links and use Coupon Code "eevblog" during checkout.  Shipping from New Zealand, international orders welcome :-)
 

Offline dentaku

  • Frequent Contributor
  • **
  • Posts: 849
  • Country: ca
Re: Why are BCD bits ordered 8-4-2-1 and not 1-2-4-8?
« Reply #10 on: January 10, 2014, 03:19:57 am »
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.
 

Offline digsys

  • Supporter
  • ****
  • Posts: 2185
  • Country: au
    • DIGSYS
Re: Why are BCD bits ordered 8-4-2-1 and not 1-2-4-8?
« Reply #11 on: January 10, 2014, 03:33:16 am »
Endianess refers to the BYTE order. The BITS in a byte remain MSB-LSB in all systems.
Hello <tap> <tap> .. is this thing on?
 

Online vk6zgo

  • Super Contributor
  • ***
  • Posts: 5365
  • Country: au
Re: Why are BCD bits ordered 8-4-2-1 and not 1-2-4-8?
« Reply #12 on: January 10, 2014, 04:54:18 am »
Endianess refers to the BYTE order. The BITS in a byte remain MSB-LSB in all systems.

I always thought it referred to the state of being of an Existentialist Native American! ;D
 

Offline han

  • Frequent Contributor
  • **
  • Posts: 308
  • Country: 00
Re: Why are BCD bits ordered 8-4-2-1 and not 1-2-4-8?
« Reply #13 on: January 10, 2014, 05:18:48 am »
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...
 

Offline digsys

  • Supporter
  • ****
  • Posts: 2185
  • Country: au
    • DIGSYS
Re: Why are BCD bits ordered 8-4-2-1 and not 1-2-4-8?
« Reply #14 on: January 10, 2014, 05:32:20 am »
Quote from: han
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... 
Yup, probably a small glitch in his brain .. happens :-)
Hello <tap> <tap> .. is this thing on?
 

Offline Dave

  • Super Contributor
  • ***
  • Posts: 1262
  • Country: si
  • I like to measure things.
Re: Why are BCD bits ordered 8-4-2-1 and not 1-2-4-8?
« Reply #15 on: January 10, 2014, 05:38:40 am »
yesterday my friend told me that he use BCD sequence like : 80-40-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?
That'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.
<fellbuendel> it's arduino, you're not supposed to know anything about what you're doing
<fellbuendel> if you knew, you wouldn't be using it
 

Offline han

  • Frequent Contributor
  • **
  • Posts: 308
  • Country: 00
Re: Why are BCD bits ordered 8-4-2-1 and not 1-2-4-8?
« Reply #16 on: January 10, 2014, 05:54:28 am »

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


 

Offline sleemanj

  • Super Contributor
  • ***
  • Posts: 2493
  • Country: nz
  • Professional tightwad.
    • The electronics hobby components I sell.
Re: Why are BCD bits ordered 8-4-2-1 and not 1-2-4-8?
« Reply #17 on: January 10, 2014, 06:30:37 am »
yesterday my friend told me that he use BCD sequence like : 20-10-8-4-2-1 .

BCD 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 = 0000
1 = 0001
2 = 0010
...
9 = 1001

That'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.

~~~
EEVBlog Members - get yourself 10% discount off all my electronic components for sale just use the Buy Direct links and use Coupon Code "eevblog" during checkout.  Shipping from New Zealand, international orders welcome :-)
 

Offline sleemanj

  • Super Contributor
  • ***
  • Posts: 2493
  • Country: nz
  • Professional tightwad.
    • The electronics hobby components I sell.
Re: Why are BCD bits ordered 8-4-2-1 and not 1-2-4-8?
« Reply #18 on: January 10, 2014, 06:35:28 am »

so the number will continuous to ..... 800-400-200-100-80-40-20-10-8-4-2-1 ?

Not really no.  Each digit is encoded as a bit sequence separately.

Eg, the number 1345 is encoded to the 4 binary sequences
0001
0011
0100
0101

(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

~~~
EEVBlog Members - get yourself 10% discount off all my electronic components for sale just use the Buy Direct links and use Coupon Code "eevblog" during checkout.  Shipping from New Zealand, international orders welcome :-)
 

Online AlfBaz

  • Super Contributor
  • ***
  • Posts: 2030
  • Country: au
Re: Why are BCD bits ordered 8-4-2-1 and not 1-2-4-8?
« Reply #19 on: January 10, 2014, 08:07:56 am »
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
 

Offline arcom

  • Contributor
  • Posts: 42
  • Country: hr
    • Arc's Lab
Re: Why are BCD bits ordered 8-4-2-1 and not 1-2-4-8?
« Reply #20 on: January 10, 2014, 08:22:03 am »
That's the Gray Code. Used a lot with rotary encoders and similar devices.
 

Offline Dave

  • Super Contributor
  • ***
  • Posts: 1262
  • Country: si
  • I like to measure things.
Re: Why are BCD bits ordered 8-4-2-1 and not 1-2-4-8?
« Reply #21 on: January 10, 2014, 08:33:55 am »

so the number will continuous to ..... 800-400-200-100-80-40-20-10-8-4-2-1 ?

Not really no.  Each digit is encoded as a bit sequence separately.
Well, you would in term split them, but they kind of are together when you convert them.

This is 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.
<fellbuendel> it's arduino, you're not supposed to know anything about what you're doing
<fellbuendel> if you knew, you wouldn't be using it
 

Offline amyk

  • Super Contributor
  • ***
  • Posts: 6809
Re: Why are BCD bits ordered 8-4-2-1 and not 1-2-4-8?
« Reply #22 on: January 10, 2014, 10:40:31 am »
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.
Did you mean SPARC? ARM is little endian by default. SPARC started as big and became bi, ARM started as little and became bi.
 

Offline woodchips

  • Frequent Contributor
  • **
  • Posts: 527
  • Country: gb
Re: Why are BCD bits ordered 8-4-2-1 and not 1-2-4-8?
« Reply #23 on: January 10, 2014, 06:31:16 pm »
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!
 

Offline SeanB

  • Super Contributor
  • ***
  • Posts: 15387
  • Country: za
Re: Why are BCD bits ordered 8-4-2-1 and not 1-2-4-8?
« Reply #24 on: January 10, 2014, 06:43:40 pm »
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.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf