B4J Question modulo alternative implementation

giggetto71

Active Member
Licensed User
Longtime User
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:
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 ;
}
 

giggetto71

Active Member
Licensed User
Longtime User
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
Top