OT: Hex to BCD conversion for programs

Richard A. Cini rcini at optonline.net
Thu Jun 29 21:51:01 CDT 2006


All:

 

            I'm working on a real-time-clock emulation for the Altair32 and
I need a push on something. Most RTC boards return a BCD value to the
caller. When you call GetLocalTime in Windows, it returns an integer value.
So, I have to somehow convert an integer to its BCD representation. 

 

            I thought about using sprintf on the integer and then returning
str[0] or str[1] depending on if I need the tens place or units place.
However, this seems to me to be an inelegant way of doing it.

 

            Does anyone have any ready-made C code to do this that I can
use? Thanks a lot!

 

Rich

 

Rich Cini

Collector of classic computers

Lead engineer, Altair32 Emulator

Web site:  <http://highgate.comm.sfu.ca/~rcini/classiccmp/>
http://highgate.comm.sfu.ca/~rcini/classiccmp/

Web site: http://www.altair32.com/ 

/***************************************************/

 




More information about the cctalk mailing list