Page 1 of 1

10bit conversion to decimal

Posted: Sat Dec 09, 2006 1:44 am
by fajc05
I am using the pic16f877a. Is there an equation or some algorithm that i could use to convert the 10bit result to decimal. I want to display the number on a 4digit 7seg display.

Posted: Mon Dec 11, 2006 11:13 am
by Benj
There is indeed an equation

Variable = 10bit result

1st Digit = Variable % 10; //Ones % Symbol = MOD
Variable = Variable / 10;

2nd Digit = Variable % 10; //Tens % Symbol = MOD
Variable = Variable / 10;

3rd Digit = Variable % 10; //Hundreds % Symbol = MOD
Variable = Variable / 10;

4th Digit = Variable % 10; //Thousands % Symbol = MOD