I had this issue short time ago, I found that a separate routine to handle units, tens, etc is more efficient and consumes less code, than splitting, of course depends on the final application, I used this routine for a timer struct number { unsigned char u; unsigned char d; unsigned char c; }; // Increase (like ++) void inc(struct number *value) { value->u++; if (value->u == 10) { value->u = 0; value->d++; } if (value->d == 10) { value->d = 0; value->c++; } if (value->c == 10) { value->c = 0; } } // Decrease (like --) void decr(struct number *value) { value->u--; if (value->u == 255) { value->u = 9; value->d--; } if (value->d == 255) { value->d = 9; value->c--; } if (value->c == 255) { value->c = 9; } } // Number = 0 void clr(struct number *value) { value->u = 0; value->d = 0; value->c = 0; } // Set value to struct void set(struct number *value, unsigned char c, unsigned char d, unsigned char u) { value->u = u; value->d = d; value->c = c; } // Test if zero unsigned char zero(struct number value) { if ((value.u == 0) && (value.d == 0) && (value.c == 0)) return 1; else return 0; } // Equal two structures void equal (struct number src, struct number *dst) { dst->u = src.u; dst->d = src.d; dst->c = src.c; } Cristo Alanis Design Engineer Tyco Electronics 2500 Courage Blvd St A Brownsville Tx 78521 > -----Original Message----- > From: piclist-bounces@mit.edu > [mailto:piclist-bounces@mit.edu] On Behalf Of picnoob > Sent: Tuesday, March 06, 2007 12:02 PM > To: piclist@mit.edu > Subject: [PIC] seperate num into tens+units > > > hi, i need a way to seperate a number, say 54. and put 5 in a > register called tens, and 4 in another called units. > > is there some binary operation to do this, or will it have to > be a custom subroutine? > > i need this kinda fast, can someone help? > -- > View this message in context: > http://www.nabble.com/seperate-num-into-tens%2Bunits-tf3356654 > .html#a9335697 > Sent from the PIC - [PIC] mailing list archive at Nabble.com. > > -- > http://www.piclist.com PIC/SX FAQ & list archive View/change > your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist