10bit conversion to decimal

For C and ASSEMBLY users to post questions and code snippets for programming in C and ASSEMBLY. And for any other C or ASM course related questions.

Moderators: Benj, Mods

Post Reply
fajc05
Posts: 3
Joined: Fri Dec 08, 2006 5:27 am
Contact:

10bit conversion to decimal

Post 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.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Post 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

Post Reply