Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int x = n / 3; // <-- make this faster
- // for instance
- int a = n * 3; // <-- normal integer multiplication
- int b = (n << 1) + n; // <-- potentially faster multiplication
- int a;
- int b;
- a = some value;
- b = a / 3;
- y = x / 3
- y = x / 3
- static inline uint32_t divby3 (
- uint32_t divideMe
- ) {
- return (uint32_t)(((uint64_t)0xAAAAAAABULL * divideMe) >> 33);
- }
- #include <stdio.h>
- void main()
- {
- int n = 1000;
- int a,b;
- a = n >> 2;
- b = (a >> 2);
- a += b;
- b = (b >> 2);
- a += b;
- b = (b >> 2);
- a += b;
- b = (b >> 2);
- a += b;
- printf("a=%dn", a);
- }
- int x = n * 0.33333333333333333333333333333333;
- int x = n >> 2; // divide by 4
Add Comment
Please, Sign In to add comment