The standard idiom for integer rounding up is:
int a = (59 + (4 - 1)) / 4;
You add the divisor minus one to the dividend.
More Related Contents:
- What is the behavior of integer division?
- sin, cos, tan and rounding error
- Math.Round doesn’t behave like i want it to. (X.0xxxxx numbers) [closed]
- Sum of the all the numbers between a and b [closed]
- Division result is always zero [duplicate]
- How does C compute sin() and other math functions?
- Round a double to x significant figures
- Mapping a numeric range onto another
- Power by squaring for negative exponents
- Java Round up Any Number
- Why is a negative int greater than unsigned int? [duplicate]
- Why does strchr take an int for the char to be found?
- “undefined reference to `pow'” even with math.h and the library link -lm [duplicate]
- In C, why is sizeof(char) 1, when ‘a’ is an int?
- Representing integers in doubles
- C: Casting minimum 32-bit integer (-2147483648) to float gives positive number (2147483648.0)
- Are floating point operations in C associative?
- Gaussian elimination without result for acceleration
- Convert char array to a int number in C
- Determine if a C string is a valid int in C
- signed and unsigned arithmetic implementation on x86
- Why does gdb evaluate sqrt(3) to 0?
- C: How to wrap a float to the interval [-pi, pi)
- To the power of in C? [duplicate]
- How does this bitwise operation check for a power of 2?
- Why is int rather than unsigned int used for C and C++ for loops?
- Why is the behavior of the modulo operator (%) different between C and Ruby for negative integers?
- Define integer (int); What’s the default value?
- Conditional tests in primality by trial division
- A possible algorithm for determining whether two strings are anagrams of one another? [closed]