|
Division by a constant is not implemented with the division instruction by any reasonable compiler. But the actual implementation is still not that fast.
|
|
|
|
|
Fueled By Caffeine wrote: coded a divide method on the old 6502 (which does not have a DIV instruction.)
Very cool! (Probably painful at the time, but very cool.)
|
|
|
|
|
Divisions are performance heavy, additions are not.
GCS d--(d+) s-/++ a C++++ U+++ P- L+@ E-- W++ N+ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- r+++ y+++* Weapons extension: ma- k++ F+2 X
|
|
|
|
|
When possible, I use multiplication instead of division.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
Me too, if the code has a potentially significant performance impact. Otherwise I use the most readable form.
In some occasions I had to ditch floating point completely and get straight to fixed point integer arithmetic - after having eliminated divisions wherever possible and memory access through matrix (a single pointer going forward of a fixed amount each cycle is extremely fast and helps any caching mechanism).
GCS d--(d+) s-/++ a C++++ U+++ P- L+@ E-- W++ N+ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- r+++ y+++* Weapons extension: ma- k++ F+2 X
|
|
|
|
|
|
Test in VS2017 - C++ Console App, Windows 7 (OEM Personalized Edition)
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
If you can arrange it to divide by a power of two, you can use the AND operator. Then look how fast that is going to be.
I have lived with several Zen masters - all of them were cats.
His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.
|
|
|
|
|
I had thought about it, but not sure if it is going to be easy to only use masking. The dynamic part are periods / frequencies
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
|
I find that very surprising. Not long I did some tests because I work on a high performance application and found the difference to be so minor that I didn't care about it.
I would like to see your code if you don't mind. Please e-mail it to me or post on my personal page if you prefer it not be shared publicly.
"They have a consciousness, they have a life, they have a soul! Damn you! Let the rabbits wear glasses! Save our brothers! Can I get an amen?"
|
|
|
|
|
I can't write you privately, you don't have the option active.
Write me an "a-mail" to this answer and I will answer you back with the code.
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
forget my previous message... I found it. (Spam filter)
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
|
I think we surrender ...
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
port == SERIAL
(sounds like cereal)
|
|
|
|
|
Let's see what you come up with tomorrow!
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I was closer than I thought with "FrayBent-O's"!
Whenever you find yourself on the side of the majority, it is time to pause and reflect. - Mark Twain
|
|
|
|
|
Hi Tim, I think audible grain port would have been better
We can’t stop here, this is bat country - Hunter S Thompson RIP
|
|
|
|
|
Ya, you could be right there.
|
|
|
|
|
Had morning tea with @Chris-Maunder about 2 hours ago.
Me bacon and Egg roll and Chips while Maunder had a coffee. He had to drive and I had to go back to work so no Shandy's this time.
Next time he has to alot more than 30 minutes in his schedule and we're dropping in on The Lord Nelson in The Rocks.
Michael Martin
Australia
"I controlled my laughter and simple said "No,I am very busy,so I can't write any code for you". The moment they heard this all the smiling face turned into a sad looking face and one of them farted. So I had to leave the place as soon as possible."
- Mr.Prakash One Fine Saturday. 24/04/2004
|
|
|
|
|
He's wanted in at least one of the 'Northern' countries for running a common website.
And you let him go...
|
|
|
|
|
Tim Deveaux wrote: And you let him go... Still worse... he has allowed him to drink coffee...
at least it was not past midnight
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
Tim Deveaux wrote: And you let him go...
Their reward was less than the Bacon and Egg with chips he bought me.
Michael Martin
Australia
"I controlled my laughter and simple said "No,I am very busy,so I can't write any code for you". The moment they heard this all the smiling face turned into a sad looking face and one of them farted. So I had to leave the place as soon as possible."
- Mr.Prakash One Fine Saturday. 24/04/2004
|
|
|
|
|
For a second you had me believe that CP was now producing tomato sauce.
I have lived with several Zen masters - all of them were cats.
His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.
|
|
|
|