At 16:16 5/3/98 +1000, Paul B. Webster VK2BZC wrote: >H=0: T=0: U=X > >C200: > if U=>200 goto CG200 >C100: > if U<100 goto C80 > H=H+1: U=U-100 >C80: > if U<80 goto C40 > T=T+8: U=U-80 > goto C10 > >CG200: > H=H+2: U=U-200 >C40: > if U<40 goto C20 > T=T+4: U=U-40 >C20: > if U<20 goto C10 > T=T+2: U=U-20 >C10: > if U<10 goto C00 > T=T+1: U=U-10 >C00: > > FWIW! > > Cheers, > Paul B. > > Hi everybody, sorry about butting into the link so late. But just got an idea, (maybe dumb on second thoughts). How about doing a binary search? H=0; T=0; U=X; while(U.bit7) /*if bit7, the definately > 128 */ { U=U-120 H=H+1 T=T+2 } while(U.bit6) /*if bit 6 .... */ { U=U-60 T=T+6 } while(U.bit5) { U=U-30 T=T+3 } while(U.bit4) { U=U-10 T=T+1 } if(U>=10) { U=U-10 T=T+1 } if(T>=20) /* if more than 20 tens */ { H=H+2 T=T-20 } elseif(T>=10) { H=H+1 T=T-10 } any comments? with best wishes and regards Sujay Sirur Email: sirur@giasbg01.vsnl.net.in Home: 604, Chitrapur Housing Society, Plot no 68, 15th Cross, 8th Main, Malleshwaram Bangalore 560 055. INDIA Tel. no: 91-80-344-3688