Ed, I have an 16F877 application that **has** to be accurate. Much of program memory plus external flash is bit-mapped in a chance game I had a look at some shift-type routines, but found that the remainder was not always accurate, even with a 0.5 test. Perhaps not quite true, but the more bits you use for the division, the more bits are in the remainder fraction, and by the time you work through those it would sometimes have been quicker to do the division the by subtraction Can't describe the game itself in detail, but basically there are three very large bit tables, all the same length. To access a number in each eg 9,473 => 9473/14 => 676 whole bytes, remainder indicates the position in the 677th byte So, anyway, this isn't fast, but it's accurate. I'm sure it could be made a little faster but it's sufficient for my application as is Hope it helps (you or someone) ;================================================ ; Divide by subtraction, ; Slow but guaranteed accurate remainder ;================================================ div14 bank0 bcf res_eq0 ;result=0 flag movlw 0x0e ;divisor movwf dsorl clrf dsorm clrf dsorh clrf dendh clrf resl ;result low clrf resh ;result high clrf rem ;remainder movf dendm,f ;test dividend for < 14 btfss zero goto dloop ;dendm > 00, continue division movlw 0x0e subwf dendl,w btfsc status,c goto dloop ;dendl > 13, continue division movf dendl,w ;dendl between 1 and 13, exit movwf rem return ;exit with result=0 + remainder ;------- division loop for num > 13 dloop btfsc dendh,7 ;test for < 00 result goto end_div bcf status,c movf dsorl,w ;subtract divisor from dividend subwf dendl,f movf dsorm,w ;ripple through high bytes btfss status,c incfsz dsorm,w subwf dendm,f movf dsorh,w btfss status,c incfsz dsorh,w subwf dendh,f incfsz resl,f goto dloop incf resh,f goto dloop end_div decfsz resl,f ;return with address movlw 0x0e ;in resh / resl addwf dendl,w ;and bit position in rem movwf rem btfss rem,7 goto test_0 movlw 0x0e ;correct any underflow addwf rem,f ;------- test result for 0 test_0 movf resl,w addwf resh,w ;add resl to resh btfsc zero ;if resl <> 00 return ;else exit with res_eq0 = 0 bsf res_eq0 return ;exit with res_eq0 = 1 -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist