In SX Microcontrollers, SX/B Compiler and SX-Key Tool, Steel wrote: I have an ADC that gives me a base2 value (0-FF) and I want to convert it to Base10 (0-9). Is there a more code-efficient way of doing so than what is below? If ADC_VALUE < 25 Then ADC_VALUE = 0 ELSEIF ADC_VALUE <50 THEN ADC_VALUE = 1 ELSEIF ADC_VALUE <75 THen ADC_VALUE = 2 ELSEIF ADC_VALUE < 100 THEN ADC_VALUE = 3 ELSEIF ADC_VALUE < 125 THEN ADC_VALUE = 4 ELSEIF ADC_VALUE < 150 THEN ADC_VALUE = 5 ELSEIF ADC_VALUE < 175 THEN ADC_VALUE = 6 ELSEIF ADC_VALUE < 200 THEN ADC_VALUE = 7 ELSEIF ADC_VALUE < 225 THEN ADC_VALUE = 8 ELSEIF ADC_VALUE < 255 THEN ADC_VALUE = 9 ENDIF ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=137056 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)