piclist 2001\04\06\123957a >
Thread: Rounding to closest 1's multiple, code enclosed :)
www.piclist.com/techref/microchip/devices.htm?key=pic
face
flavicon
face BY : Scott Dattalo email (remove spam text)



On Fri, 6 Apr 2001, [Iso-8859-1] Kübek Tony wrote:

> Hi,
>
> Scott Dattalo wrote:

Actually Bob. And it's a damned clever idea.

{Quote hidden}

actually the 10's aren't much harder:

lo + 256*mid + 65536*hi = lo +250*mid + 65530*hi + 6*(mid + hi)

  clrf   h2
  movf   mid, w
  addwf  hi,w
  rlfc   h2,f
  movwf  l2       ;mid+hi
  addwf  l2,f     ;2*mid+2*hi
  skpnc
   incf  h2,f
  addwf  l2,f     ;3*mid+3*hi
  skpnc
   incf  h2,f

  clrc      rlf    temp,w   ;6*mid+6*hi
  skpnc
   incf  h2,f

  addwf  lo,w
  skpnc
   incf  h2,f

at this point, h2:l2 is congruent to the original 24-bit number modulo 10 and is
no more than 14-bits. But this is off the top of my head and not necessarily
optimized...


>
> Brilliant !

Yeah! Let's by Bob a beer.

Scott

--
http://www.piclist.com hint: To leave the PICList
KILLspampiclist-unsubscribe-requestEraseMEspamKILLspammitvma.mit.edu


<Pine.LNX.4.21.0104061117510.9763-100000@tempest2.blackhat.net> QUOTED-PRINTABLE

In reply to: <200104061514.RAA02328@mn10.swip.net>
See also: www.piclist.com/techref/microchip/devices.htm?key=pic
Reply You must be a member of the piclist mailing list (not only a www.piclist.com member) to post to the piclist. This form requires JavaScript and a browser/email client that can handle form mailto: posts.
Subject (change) Rounding to closest 1's multiple, code enclosed :)

month overview.

new search...