Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > sci.electronics.design > #503435

Re: OT: PIC16 divide and/or multiply routines

From "Tim Williams" <tiwill@seventransistorlabs.com>
Newsgroups sci.electronics.design
Subject Re: OT: PIC16 divide and/or multiply routines
Date 2018-04-25 03:25 -0500
Organization A noiseless patient Spider
Message-ID <pbpdvr$eei$1@dont-email.me> (permalink)
References <xvYYx.43198$Iw3.9957@fx30.iad> <4a9c4182-fe21-4b20-a35e-9c24e7b56d6a@googlegroups.com> <pbmpn0$1v82$1@gioia.aioe.org> <pbof7b$l2o$1@dont-email.me> <pbpb7n$3nq$2@gioia.aioe.org>

Show all headers | View raw


"Martin Brown" <'''newspam'''@nezumi.demon.co.uk> wrote in message 
news:pbpb7n$3nq$2@gioia.aioe.org...
>> 99/61 is only -.003% off.
>
> Try dividing by 61 with just shifts and adds!

Easy, multiply by 1074. :-)

(I once wrote a one of these for AVR, for decimal conversion.  The 
divide-by-10 operation takes only ~30 cycles, thanks to the fast hardware 
(8x8) multiply, and using this trick instead of long division.  Yes, 
quotient and remainder are produced as usual.  Downside: the operation had 
to be a full 24 bits, to maintain exact results for all inputs.  That is, 
for a 16 bit input, it's multiplied not by 6553, but a bit more, and 
shifted.)

Tim

-- 
Seven Transistor Labs, LLC
Electrical Engineering Consultation and Contract Design
Website: https://www.seventransistorlabs.com/ 

Back to sci.electronics.design | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Re: OT: PIC16 divide and/or multiply routines ramiserhan77@gmail.com - 2018-04-23 08:48 -0700
  Re: OT: PIC16 divide and/or multiply routines bill.sloman@ieee.org - 2018-04-23 19:33 -0700
  Re: OT: PIC16 divide and/or multiply routines Terry Newton <nbill@bellsouth.net> - 2018-04-24 05:12 +0000
  Re: OT: PIC16 divide and/or multiply routines Martin Brown <'''newspam'''@nezumi.demon.co.uk> - 2018-04-24 09:26 +0100
    Re: OT: PIC16 divide and/or multiply routines John S <Sophi.2@invalid.org> - 2018-04-24 18:39 -0500
      Re: OT: PIC16 divide and/or multiply routines Martin Brown <'''newspam'''@nezumi.demon.co.uk> - 2018-04-25 08:37 +0100
        Re: OT: PIC16 divide and/or multiply routines "Tim Williams" <tiwill@seventransistorlabs.com> - 2018-04-25 03:25 -0500
          Re: OT: PIC16 divide and/or multiply routines Clifford Heath <no.spam@please.net> - 2018-04-25 19:57 +1000
        Re: OT: PIC16 divide and/or multiply routines Jasen Betts <jasen@xnet.co.nz> - 2018-04-26 07:24 +0000
          Re: OT: PIC16 divide and/or multiply routines David Brown <david.brown@hesbynett.no> - 2018-05-04 15:40 +0200
  Re: OT: PIC16 divide and/or multiply routines Spehro Pefhany <speffSNIP@interlogDOTyou.knowwhat> - 2018-04-24 08:51 -0400
    Re: OT: PIC16 divide and/or multiply routines upsidedown@downunder.com - 2018-04-24 22:38 +0300
      Re: OT: PIC16 divide and/or multiply routines gnuarm.deletethisbit@gmail.com - 2018-04-25 11:15 -0700
        Re: OT: PIC16 divide and/or multiply routines Clifford Heath <no.spam@please.net> - 2018-04-26 09:35 +1000
    Re: OT: PIC16 divide and/or multiply routines Martin Brown <'''newspam'''@nezumi.demon.co.uk> - 2018-04-25 08:38 +0100
      Re: OT: PIC16 divide and/or multiply routines gnuarm.deletethisbit@gmail.com - 2018-04-25 11:18 -0700
        Re: OT: PIC16 divide and/or multiply routines Martin Brown <'''newspam'''@nezumi.demon.co.uk> - 2018-04-26 08:56 +0100
    Re: OT: PIC16 divide and/or multiply routines bitrex <user@example.net> - 2018-04-25 11:56 -0400

csiph-web