Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to split a number into variables?

Status
Not open for further replies.

psmeets

Junior Member level 1
Joined
Apr 25, 2001
Messages
16
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
52
Hi,

I am working on a 3 digit counter and want to display a number, let's say '263'. This value is stored in a variable (word).

To display the number correctly I need to split this number into three separate variables.

e.g.
2 into var1
6 into var2
3 into var3


Can anybody help me with a piece of code of with a hint?

Thanks!

Patrick
 

unsigned int in_data;
unsigned char a,b,c;

a=in_dat%10;
b=((in_dat-a)%100)/10;
c=((in_dat-a-10*b)%1000)/100;
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top