473,406 Members | 2,378 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

BCD to decimal conversion in C program

I am working on a project using microchip PIC16F946, for RF controller. The current code have a working private ID code in binary. The LCD has 4 digits And 4 binary digits can only handle a miax of 16 IC code (1111). Now I want to increade the code to random number or as many ID number as need. So I want to use these 4 bidits as 4 BCD. And convert these 4 BCD digits into 16 pure binary or into decimal number. As you know 1 BCD represents 0 to 9 in decimal oe 1 BCD represnts 8 binary bits.

Anyone, please help me to write a working code to convert 4 BCD digits to 16 Binary or decimal.

Private email is provides here: Feel free to answer to this email:
<removed>

Hope some expertise, samart people out there will reach out and help.

Thanks.

learnc
Jul 26 '10 #1
1 19910
newb16
687 512MB
There is no need to convert BCD to decimal, because BCD is already decimal, where each digit is from 0 to 9, encoded by 4 binary digits. Converting to binary will be something like this
Expand|Select|Wrap|Line Numbers
  1. for(i=0;i<4;i++)
  2. {
  3. result *= 10;
  4. result += bcd[i];
  5. }
Jul 26 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: nyy | last post by:
Hello everybody on this group. I have this program that is supposed to display a temp. conversion from fahrenheit to celsius, can anybody kindly can tell me what is wrong? Thanks. <!DOCTYPE html...
3
by: Ven | last post by:
Hi, I want to convert a decimal feild into a packed decimal field in my C++ program. How can I do that ? Is there any functions in C++ that can do that. I am using g++ compiler to compile my...
21
by: AsheeG87 | last post by:
Hey Everyone~ I'm still a C++ Rookie so please bear with me on this. I'm doing a temperature conversion program with prototype functions. Basicly, I was wondering if some of you would take a look...
7
by: billbaitsg | last post by:
Hi, I need some help with figuring out why my program is all messed up. There are two portions two it, one that converts from roman to decimal (rom2dec) and another that converts from decimal to...
14
realin
by: realin | last post by:
hi guys i am trying to make a program to convert decimal number into binary .. i am able to do that, but the number comes inverted.. like 1101 comes like 1011 now how do i swap it off.. ...
7
by: GreggaR0und | last post by:
Hello; I am reading a file that is ODBC-linked directly to an AS400 machine in a VBscript program within Access. One of the fields in this file automatically gets defined as a Binary data type in...
4
by: DixitSolanki | last post by:
I want to convert ASCII hex number to decimal conversion. For Example : 1: F01A is converted into Decimal: 61466 2: FFFC64F0 is converted into Decimal: 4294730992 What is the best...
1
by: selvakumari | last post by:
I am doing decimal conversion in my code as below if datachNode.InnerText is "147.00" and scaleFactor.InnerText is "1" decimal value = Convert.ToDecimal(datachNode.InnerText.ToString());...
1
by: Don Hillgen | last post by:
I need to expand a field in a db2 table, must I write a conversion program???
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.