pic microcontroller discussion list wrote: > I think the O.P was talking about a "2" as the second > digit from the right in the *decimal* representation of > the long. And how to know if the value is between 20 and 29 > *or* between 120 and 129 *or* between 220 and 229 and so on. > And then, in thoses cases, subtract 20. OK, try signed char tens; tens = (lval%100)/10; lval -= (10*tens); lval += (10*newtens); It should be fairly easy to produce a generic version of this for any digit, but it's not pretty, and may be slower than Jan-Erik's suggestion of bin-bcd-bin. TIMTOWDI, as they say in Perl... Nigel (TIMTOWDI = "There is more than one way to do it") -- Nigel Orr, Design Engineer nigel@axoninstruments.co.uk Axon Instruments Ltd., Wardes Road,Inverurie,Aberdeenshire,UK,AB51 3TT Tel:+44 1467 622332 Fax:+44 1467 625235 http://www.axoninstruments.co.uk -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads