piclist 2000\12\06\141757a >
Thread: Hex to BCD in C
www.piclist.com/techref/language/index.htm?key=c
picon face BY : Brent Brown email (remove spam text)



Not sure if this what you want, but you might get some ideas from
it. It takes a signed 16 bit integer and outputs the representative
ASCII characters. In this example SendByte() outputs to the serial
port. Output is from "-32767" to "+32768". For unsigned values
delete the first 5 lines of this function. Easy to modify for different
lengths too.

void SendNumSInt(int x){
       if(x < 0)
               SendByte('-');
       else
               SendByte('+');
       x=abs(x);

       SendByte((x/10000) + '0');
       SendByte((x%10000)/1000 + '0');
       SendByte((x%1000)/100 + '0');
       SendByte((x%100)/10 + '0');
       SendByte((x%10) + '0');
}

Brent Brown
Electronic Design Solutions
16 English Street
Hamilton, New Zealand
Ph/fax: +64 7 849 0069
Mobile/text: 025 334 069
eMail:  brent.brown.....spamclear.net.nz

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email spamBeGonelistservTakeThisOuTspamspammitvma.mit.edu with SET PICList DIGEST in the body


<3A2F47D0.30820.405B444@localhost> 7BIT

In reply to: <000d01c05f7a$04a8e400$1701a8c0@johnspc>
See also: www.piclist.com/techref/language/index.htm?key=c
Reply You must be a member of the piclist mailing list (not only a www.piclist.com member) to post to the piclist. This form requires JavaScript and a browser/email client that can handle form mailto: posts.
Subject (change) Hex to BCD in C

month overview.

new search...