Easily Convert Decimal Numbers To Their Binary And BCD Formats: Backstory

Oct. 2, 2008
HERE’S A C/C++ PROGRAM that converts decimal numbers ranging from 0 to 99,999 to binary and binary coded decimal (BCD) formats. Using a simple algorithm in conjunction with pointer arithmetic and bitwise shifting increases the conversion sp

For a long time, circa 1990s, based on my own design issues, the problem of presenting decimal/binary data on numeric displays consisting of more then two digits was always a challenge. All the software and available hardware relating BCD to decimal displays always discussed the designs based on two digits.

The key to my thinking was the development of some algorithm that would be able to convert decimal/binary information to BCD information of any numeric size. Following up on this thinking was to first determine how a decimal number of multiple digits relates via its binary equivalent to the final BCD number.

Once I determined this relationship, then the rest was developing a computer program that could generate this end result. The first program was actually written in Basic. Additional refinements that the program indeed “worked” allowed me to convert the program statements to a more useable form for engineering application to a C/C++ program.

The major challenge was to develop an algorithm, which showed the relationship between decimal/binary to BCD data. The design approach used for the development of the algorithm is still appropriate in today’s design world. The algorithmic design is still applicable for today’s technological development. Wherever presentation of BCD information is required, this design has great relevance.

Sponsored Recommendations

What are the Important Considerations when Assessing Cobot Safety?

April 16, 2024
A review of the requirements of ISO/TS 15066 and how they fit in with ISO 10218-1 and 10218-2 a consideration the complexities of collaboration.

Wire & Cable Cutting Digi-Spool® Service

April 16, 2024
Explore DigiKey’s Digi-Spool® professional cutting service for efficient and precise wire and cable management. Custom-cut to your exact specifications for a variety of cable ...

DigiKey Factory Tomorrow Season 3: Sustainable Manufacturing

April 16, 2024
Industry 4.0 is helping manufacturers develop and integrate technologies such as AI, edge computing and connectivity for the factories of tomorrow. Learn more at DigiKey today...

Connectivity – The Backbone of Sustainable Automation

April 16, 2024
Advanced interfaces for signals, data, and electrical power are essential. They help save resources and costs when networking production equipment.

Comments

To join the conversation, and become an exclusive member of Electronic Design, create an account today!