Created
October 8, 2018 16:57
-
-
Save ahills60/83c53c9a9c6461baf978376154c2cae2 to your computer and use it in GitHub Desktop.
Compute the ceiling of an integer division without floating point
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include <stdio.h> | |
#include <stdint.h> | |
#define ceilu32(x, y) ((((((uint32_t) x) << 16) / (uint32_t) y) + 0xffff) >> 16) | |
int main(void) | |
{ | |
uint16_t var1, var2, result; | |
for (var1 = 1; var1 <= 50000; var1++) | |
{ | |
for (var2 = 1; var2 <= 50000; var2++) | |
{ | |
result = ceilu32((var1, var2); | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment