giggetto71 Active Member Licensed User Longtime User Oct 10, 2021 #1 Hi, I have found here what it looks a very fast alternative to modulo but I doubt it can be implemented with B4X. Can you confirm please? thanks C: Copy uint32_t mod1(uint32_t x, uint32_t N) { return x % N; } uint32_t mod2(uint32_t x, uint32_t N) { return ((uint64_t) x * (uint64_t) N) >> 32 ; }
Hi, I have found here what it looks a very fast alternative to modulo but I doubt it can be implemented with B4X. Can you confirm please? thanks C: Copy uint32_t mod1(uint32_t x, uint32_t N) { return x % N; } uint32_t mod2(uint32_t x, uint32_t N) { return ((uint64_t) x * (uint64_t) N) >> 32 ; }
Erel B4X founder Staff member Licensed User Longtime User Oct 11, 2021 #2 What are you trying to solve? Have you encountered any performance issues with the built in modulo operator? Upvote 0
What are you trying to solve? Have you encountered any performance issues with the built in modulo operator?
giggetto71 Active Member Licensed User Longtime User Oct 11, 2021 #3 No no, no issue with mod. I am just going through my code and search for places where i can do the same thing faster, and since some functions are obviously slower than other i am trying to focus on them,but dont worry..i still have plenty of other stuff to optimize. By the way do you have a list of tips for speed or things to avoid if you have to go fast? Upvote 0
No no, no issue with mod. I am just going through my code and search for places where i can do the same thing faster, and since some functions are obviously slower than other i am trying to focus on them,but dont worry..i still have plenty of other stuff to optimize. By the way do you have a list of tips for speed or things to avoid if you have to go fast?
Erel B4X founder Staff member Licensed User Longtime User Oct 11, 2021 #4 giggetto71 said: By the way do you have a list of tips for speed Click to expand... Yes. Most important one is: preoptimization is very bad. You will just waste your time and it will have exactly zero impact on the app performance. B4X Programming Video Tutorials www.b4x.com Upvote 0
giggetto71 said: By the way do you have a list of tips for speed Click to expand... Yes. Most important one is: preoptimization is very bad. You will just waste your time and it will have exactly zero impact on the app performance. B4X Programming Video Tutorials www.b4x.com