source:
Deliverables/D4.1/GCC/FastRoundup.c
@
297
Last change on this file since 297 was 169, checked in by , 11 years ago | |
---|---|
File size: 269 bytes |
Line | |
---|---|
1 | /* For 16 bit unsigned integers. */ |
2 | unsigned int round_up(unsigned int v) |
3 | { |
4 | v--; |
5 | v |= v >> 1; |
6 | v |= v >> 2; |
7 | v |= v >> 4; |
8 | v |= v >> 8; |
9 | v++; |
10 | return v; |
11 | } |
12 | |
13 | int main() |
14 | { |
15 | unsigned int f; |
16 | f = round_up(125); |
17 | if(f == 128) |
18 | return 5; |
19 | else |
20 | return 7; |
21 | } |
Note: See TracBrowser
for help on using the repository browser.