473,395 Members | 1,622 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,395 software developers and data experts.

Binary Coded Decimal (BCD) how to convert???

hello,

i have two int values which i have to write into an byte (using bcd
notation) and send it to
network resource.

my question is now, how can i convert the int value to bcd an store this
information in
an byte and also the other way?

greets jochen
Nov 16 '05 #1
2 17872
Jochen Stuempfig wrote:
hello,

i have two int values which i have to write into an byte (using bcd
notation) and send it to
network resource.

my question is now, how can i convert the int value to bcd an store this
information in
an byte and also the other way?

greets jochen

public Byte toBCD(int ileft, int iright)
{
return Convert.ToByte(ileft*16+iright);
}

David Logan
Nov 16 '05 #2
thanks works great.

jochen

"David logan" <da*********@g1.com> schrieb im Newsbeitrag
news:GC8Oc.181553$IQ4.162019@attbi_s02...
Jochen Stuempfig wrote:
hello,

i have two int values which i have to write into an byte (using bcd
notation) and send it to
network resource.

my question is now, how can i convert the int value to bcd an store this
information in
an byte and also the other way?

greets jochen

public Byte toBCD(int ileft, int iright)
{
return Convert.ToByte(ileft*16+iright);
}

David Logan

Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Mariusz Sakowski | last post by:
I'm writing class which will be able to store large numbers (my ambition is to make it able to operand on thousands of bits) and perform various operations on it (similiar to those available with...
7
by: hana1 | last post by:
Hello experts, I used to program in C/C++ and now switched to Java. I am having a difficulty that I need your help with. How can I limit a double variable to hold 2 decimal points only? Say I...
21
by: nephish | last post by:
i have an interesting project at work going on. here is the challenge. i am using the serial module to read data from a serial input. it comes in as a hex. i need to make it a binary and compare it...
8
by: bearophileHUGS | last post by:
Hello, I have four things to ask or to suggest, sorry if they seem basic or already discussed. ------------------- I am still ignorant about Tkinter. This little program, after pressing the...
8
by: Gopal | last post by:
Hello: Can anybody suggest a code or modify the following chunk of code for converting a decimal to BCD and viceversa for unsigned long integers. The following code works good for integers but...
687
by: cody | last post by:
no this is no trollposting and please don't get it wrong but iam very curious why people still use C instead of other languages especially C++. i heard people say C++ is slower than C but i can't...
5
by: Speed | last post by:
Hi, I have a 57000 bit long binary number and I want to save it to a file. At the moment I am using an unsigned char array to store the array and then fwrite to store it as follows. fwrite(...
3
by: zgfareed | last post by:
My program converts decimal numbers from to binary and hexadecimal. I am having trouble with my output which is supposed to be in a certain format. Binary needs to be in the format of XXXX XXXX...
0
Frinavale
by: Frinavale | last post by:
Convert a Hex number into a decimal number and a decimal number to Hex number This is a very simple script that converts decimal numbers into hex values and hex values into decimal numbers. The...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...

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.