1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- #include "util.h"
- int32_t pow_int(int16_t b, uint8_t e)
- {
- int32_t x, y;
- if (!e)
- return 1;
- x = b;
- while (!(e & 1)) {
- e = (uint8_t)(e >> 1);
- x *= x;
- }
- y = x;
- e = (uint8_t)(e >> 1);
- while (e) {
- x *= x;
- if (e & 1)
- y *= x;
- e = (uint8_t)(e >> 1);
- }
- return y;
- }
|