![]() |
![]() |
#1 |
Jan 2005
13 Posts |
![]()
1. A 16-bit register in a computer contains 10110011 11000100. What does its contents represent if it contains
a) a 4-digit decimal number in the BCD(binary coded decimal) code, HEre what i have: First i convert binary to decimal and have 46020 in decimal. Then i use the BCD table in the book to convert it from decimal to BCD. Answer= 0100 0110 0000 0001 0000 Please check if i did it wrong. Thanks alot |
![]() |
![]() |
![]() |
#2 |
P90 years forever!
Aug 2002
Yeehaw, FL
22×5×397 Posts |
![]()
Does anyone still use BCD? Do they still teach this stuff?
My rusty recollections tell me you have an illegal BCD number as input. I suggest googling BCD or "binary coded decimal" and figuring it out. |
![]() |
![]() |
![]() |
#3 |
Aug 2002
26×5 Posts |
![]()
I'd say this sounds like homework, but I have no idea what class teaches BCD anymore.
|
![]() |
![]() |
![]() |
#4 |
Oct 2004
tropical Massachusetts
3×23 Posts |
![]()
Heh, the Intel x87 FPU supported loading and storing an 80-bit packed decimal format (10-byte, 1 sign byte and 18 digits with the remaining 9 bytes), and consequently to this day so does any modern x86 processor. The internal register representation is the standard one though. Well, standard Intel "extended-precision double".
|
![]() |
![]() |
![]() |
#5 | |
"Richard B. Woods"
Aug 2002
Wisconsin USA
22×3×641 Posts |
![]() Quote:
1 (decimal) = 0001 (BCD) 2 (decimal) = 0010 (BCD) 3 (decimal) = 0011 (BCD) 4 (decimal) = 0100 (BCD) 5 (decimal) = 0101 (BCD) 6 (decimal) = 0110 (BCD) 7 (decimal) = 0111 (BCD) 8 (decimal) = 1000 (BCD) 9 (decimal) = 1001 (BCD) The register content 1011 0011 1100 0100 is not itself a 4-digit BCD number because neither 1011 nor 1100 is a BCD digit. BCD also interpreted the other 6 bit sequences as plus or minus signs -- 1011 and 1101 were minus signs, while 1010, 1100, 1110 and 1111 were plus signs. (Yes, two codes for the minus sign and four codes for the plus sign.) (Why not three codes for each sign? (*sigh*) It's a long story.) So, 1011 0011 1100 0100 could be interpreted as BCD "-3+4", but that's not a 4-digit decimal number. - - - And yes, packed decimal format is derived from BCD codes -- even the plus/minus signs (in IBM's packed decimal, anyway). Last fiddled with by cheesehead on 2005-09-13 at 03:44 |
|
![]() |
![]() |
![]() |
#6 |
Jun 2003
32×17 Posts |
![]()
Cheesehead's answer is partly correct but incomplete (as he left out the last 6 "digits"). IBM's hexadecimal BCD code has 16 characters, 0 - 9 and A - F.
Here are the missing characters: A (decimal) = 1010 (BCD) B (decimal) = 1011 (BCD) C (decimal) = 1100 (BCD) D (decimal) = 1101 (BCD) E (decimal) = 1110 (BCD) F (decimal) = 1111 (BCD) Consequently, 1011 0011 1100 0100 = B 3 C 4 and is considered by IBM mainframe programmers as a 4 digit hexadecimal number which can be added, subtracted, multiplied, etc. like any other number. This is where, I think, the expression "A + 1 = B" came from (e.g. 1010 + 0001 = 1011 or A+1 = B). Last fiddled with by RMAC9.5 on 2005-09-16 at 21:29 |
![]() |
![]() |
![]() |
#7 | |
Cranksta Rap Ayatollah
Jul 2003
641 Posts |
![]() Quote:
|
|
![]() |
![]() |
![]() |
#8 | ||
"Richard B. Woods"
Aug 2002
Wisconsin USA
22·3·641 Posts |
![]()
RMAC9.5,
I started programming computers in 1963. At that time (which was before IBM announced its System/360), many mainframes (IBM and others) used word lengths that were a multiple of 3 bits, the number system most commonly used (other than binary and decimal) was octal (base-8), and character codes were 6 bits long, not 8. Hexadecimal was not commonly used by programmers (except possibly on a few obscure non-IBM systems) at that time. In its System/360 introductory documents, IBM had to include explanations of the hexadecimal system and how it was related to binary, octal, and decimal, because few programmers were familiar with it. Quote:
As TravisT pointed out, the D in BCD stands for Decimal, not "Hexadecimal". Quote:
In the Binary-Coded Decimal system, the four-bit binary values whose decimal equivalents are 10, 11, 12, 13, 14, and 15 are interpreted as sign (+ or -) codes, not numeric digits. tinhnho quoted "1. A 16-bit register in a computer contains 10110011 11000100. What does its contents represent if it contains a) a 4-digit decimal number in the BCD(binary coded decimal) code". It is possible that the writer of that question made a mistake -- the reference to BCD doesn't really match the register value presented. I've worded my previous responses under the assumption that the writer meant what s/he said, but that might not actually be true. - - - - - Also see http://en.wikipedia.org/wiki/Binary-coded_decimal Last fiddled with by cheesehead on 2005-09-17 at 05:09 |
||
![]() |
![]() |
![]() |
#9 |
Jun 2003
2318 Posts |
![]()
Cheesehead, as I was composing my reply a little voice inside my head kept whispering "you are are describing EBCDIC (extended binary coded decimal interchange code) hexadecimal numbers, maybe they are different than BCD decimal numbers"; and "Cheesehead sounds like he might have personal experience (i.e. knows what he is talking about)". Thanks for the history lesson as my IBM mainframe experience dates from 1975 on System 370 machines and I have sometimes wondered what EBCDIC was extended from.
|
![]() |
![]() |
![]() |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
convert files from srsieve/srfile into worktodo.txt | Rincewind | PrimeNet | 9 | 2014-11-01 11:47 |
How to convert 5495-bit binary number to decimal? | Stargate38 | Software | 12 | 2012-02-07 21:19 |
convert 3d into 2d | nuggetprime | Programming | 6 | 2007-09-22 08:35 |
convert to standard ASCII text when possible? | ixfd64 | mersennewiki | 5 | 2006-04-06 00:00 |
Linux! Convert me! | OmbooHankvald | Linux | 8 | 2005-08-13 23:50 |