My read of the question was to convert the byte value to packed BCD to send to consul. how the consul would display them would depend on the consul I guess. That is why I mentioned the term BCD, as using that term would have avoid confusion. But he could want a ASCII representation of the decimal value of the byte. If he wants to see if the byte is a printable character or a control character (or other nonprintable character), I would recommend he convert the byte to two hex ASCII characters. May be easier to look up on ASCII code charts. Bill ----- Original Message ----- From: "Michael Rigby-Jones" To: "Microcontroller discussion list - Public." Sent: Tuesday, April 12, 2005 3:24 AM Subject: RE: [PIC] : hex or binary to decimal > > > >-----Original Message----- > >From: piclist-bounces@mit.edu [mailto:piclist-bounces@mit.edu] > >Sent: 12 April 2005 11:21 > >To: Microcontroller discussion list - Public. > >Subject: Re: [PIC] : hex or binary to decimal > > > > > >What you are describing is to convert to a BCD or Binary > >Coded Decimal. Where each byte contains the hex value 0 to 9. > >This only uses the Least Significant 4 Bits of a byte, leaving > >the Most Significant 4 Bits unused. > > > >And you want to pack the digits and have two decimal digits in > >one byte. > > > >Important Things That Only Have Letters > > > >The least significant bit ( LSB ) is the > >bit position in a byte having the value of 1. > > > >The most significant bit ( MSB ) is the > >bit position in a (8 bit) byte having the value of 128.. > > > >In BCD, numbers are represented as a sequence of decimal > >digits in which each digit is represented by four bits. > > > >Storing two decimal digits per (8 bit) byte, is called "packed" BCD. > > > > > >Bill > > It's not quite BCD, as BCD stores the decimal value for each digit. > However, it's a trival matter to covert this to ASCII by adding 48 to > each digit (ASCII '0'). > > Regards > > Mike > > ======================================================================= > This e-mail is intended for the person it is addressed to only. The > information contained in it may be confidential and/or protected by > law. If you are not the intended recipient of this message, you must > not make any use of this information, or copy or show it to any > person. Please contact us immediately to tell us that you have > received this e-mail, and return the original to us. Any use, > forwarding, printing or copying of this message is strictly prohibited. > No part of this message can be considered a request for goods or > services. > ======================================================================= > > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist