Hi, late reply, been out of the loop for a while, anyway, Edson Brusque wrote: > The only problem I've found if when going from 0 to 255 or from 255 to 0: > > filt =3D filt + ((new - filt)+1) / 2 > filt =3D 0 + ((255 - 0)+1) / 2 <--- 255+1=3D256, it will roll to = 0 > filt =3D 0 + (0) / 2 > filt =3D 0 <--- should be 255 > > Anyway, I can solve this doing 16 bit operations or (easier) with a > couple of "if" clauses. Well remember that you actually have 9 bit's in the working register, you can also use the carry, in this case, assuming the constants you use and the flow, would give: filt =3D filt + ((new - filt)+1) / 2 filt =3D 0 + ((255 - 0)+1) / 2 <--- 255+1=3D256, it will roll to 0 ** = and carry will be set ** filt =3D 0 + (0) / 2 <---- use RRF, it will roll in the = carry as top bit and produce filt =3D 128 <--- should be 255 **nope** should be 128 ( ffrac is =3D 2 = ) /Tony -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu