Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
06/06/04 08:04
Read: times


 
Msg Score: +1
 +1 Good Answer/Helpful
#71888 - RE: 16bit Binary to BCD with decimal
Responding to: ???'s previous message
Sajid:
Conversion of numbers similar to what you want to do has clearly been coded many times. Often there are a number of steps involved. You should check out the Code Library on this site (see the button to the left). There are a number of number conversion routines there that will give you a start.

Please note that the intrinsic information contained in a binary 16-bit word is usually considered to be an integer. It may be an unsigned value with a range of 0 to 65535 or it may be a signed value with a range from -32768 to +32767. As such with the typical conversion of an integer value you will end up with no decimal places in the result.

There is a technique that is often used in programming wherein integer values are scaled representations of the actual real world parameter values. Take for example where you want two decimal places in your converted data you may choose to let the 16-bit integer data represent the real world data multiplied by 100. In this case the 16-bit unsigned value can represent read world data from 0.00 to 655.35. Similarly signed data can represent real world values from -327.68 to +327.67. If you use a system like this then you just convert the 16-bit values as integers and then plug in an assumed decimal point between the second and third digits of the converted results.

Good Luck
Michael Karas


List of 5 messages in thread
TopicAuthorDate
16bit Binary to BCD with decimal            01/01/70 00:00      
   RE: 16bit Binary to BCD with decimal            01/01/70 00:00      
   RE: 16bit Binary to BCD with decimal            01/01/70 00:00      
   RE: 16bit Binary to BCD with decimal            01/01/70 00:00      
   RE: 16bit Binary to BCD with decimal            01/01/70 00:00      

Back to Subject List