Fagundes:
I don't know in C, but I have a routine in .ASM.
If you need, tell me.
Sorry, my English is bad.....
Andres.
Cordoba - Argentina.
Fagundes Elrica escribi
Ok, but in the other side?
I get the number 1320 in BCD and i want to convert in bin (or hex). How i do
that?
---------------------------------
To: p...
From: e...@online.no
Date: Sun, 3 Jun 2007 18:07:58 +0200
Subject: Re: [piclist] bcd 16 bits to bin
"Just keep in mind the weight of each bcd digit in a binary number is 16... "
So...
(16x16x5) + (16x1x2) + (1x8) = 1320(dec) And for 3C7E(hex), vhich is
15486(dec):
(16x16x16x3) + (16x16xC) + (16x1x7) + (1xE) = 15486(dec)
12288 + 3072 + 112 + 14 = 15486(dec) Keep in mind that mul
by 16 can be done by:
-Rotate Left 4 times
-Loading a nibble(4bits)
-Swapping nibbles, and merging / masking For the digit multiplication
you'll probably have to use a proper multiplication routine,
minimum a 4by8 , with 12 or 16bit output.
Fagundes Elrica wrote: Ok! But if my number is a 16 bits value?
Example= 1320 (bcd) = 528 (hex) --- How i do the conversion??
---------------------------------
To: p...
From: e...@online.no
Date: Sun, 3 Jun 2007 11:52:03 +0200
Subject: Re: [piclist] bcd 16 bits to bin
This is not C but...
E.g
9A(bcd)
01(9) 1010(A) (bin)
(16x9) + (1xA) = 154(dec) Just keep in mind the weight of each bcd digit in a
binary number is 16...
So for a 2-digit BCD number you simply multiply the MSD by 16, and then add the
LSD and you have the binary. OK?
falcosms wrote: Hi I need a code example for conversion of a 16 bits
BCD data in BIN , in
C (ccs PIC) []s Marcelo
--
*******************************************
VISIT MY HOME PAGE:
LAST UPDATED: 23/08/2003
*******************************************
Regards
Eirik Karlsen
---------------------------------
Hotmail to go? Get your Hotmail, news, sports and much more! Check out the New
MSN Mobile
--
*******************************************
VISIT MY HOME PAGE:
LAST UPDATED: 23/08/2003
*******************************************
Regards
Eirik Karlsen
---------------------------------
Hotmail to go? Get your Hotmail, news, sports and much more! Check out the New
MSN Mobile
---------------------------------
Pregunt Respond Descubr
Todo lo que quers saber, y lo que ni imaginabas,
esten Yahoo! Respuestas (Beta).
Probalo ya!
bcd 16 bits to bin
Started by ●June 2, 2007