In SX Microcontrollers, SX/B Compiler and SX-Key Tool, johncouture wrote: Thank you Michael and Bean, that helped a lot. Bean with your new Word variables it seems we can do a lot more. Based on the examples both you and Michael provided here is a derivative work that should handle values up to $FFFF (65,000). I took out the negative sign stuff: '--------------------------------------------------------------------------- Bin16DEC: ' Use: Bin16DEC word ' -- Convert a 16bit binary variable into a decimal value. ' Note add 30h to each ascDigit to directly output ' to a terminal or LCD. ' Original versions by Bean (Hitt Consulting) & Michael Chadwick ' ' Setup ' wrdTemp var WORD ' wrcDivisor var WORD ' ascDigit var Byte(5) IF __PARAMCNT = 1 THEN ' if parameter is a Byte or Word variable wrdTemp = __PARAM1 ELSE wrdTemp = __WPARAM12 ENDIF ' fill all locations with blanks PUT ascDigit, BLANK, BLANK, BLANK, BLANK, BLANK, BLANK, BLANK Bin16DEC1: x1 = 4 ' position in array wrdDivisor = 10000 ' set initial power of 10 Bin16DEC2: IF wrdTemp < wrdDivisor THEN Bin16DEC3 ' continue to loop? inc ascDigit(x1) ' increment digit in appropriate position wrdTemp = wrdTemp - wrdDivisor ' subtract 10 power from word variable goto Bin16DEC2 Bin16DEC3: dec x1 ' decrement position counter wrdDivisor = wrdDivisor / 10 ' divide power of 10 if x1 > 0 THEN Bin16DEC2 ' more digits to process? ascDigit(x1) = wrdTemp_LSB ' take care of last (right most) digit RETURN ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=138199#m138289 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)