I would like to know how I could ignore rounding in divisions, for example:
4/3 = 1.33 ... ~ 1 | 5/3 = 1.66 ... ~ 2
Right?
I wanted to make a program in C, that in these cases, rounding is not done, because the idea is to increment a number if it contains decimals, regardless of whether the decimal number is greater, less than or equal to 5 Any ideas?
Code:
void main() {
float n1 = 4.0;
float n2 = 3.0;
float result;
result = n1 / n2; // res = 1,33 ~ 1
// Aqui eu quero que o resultado seja 2
printf("Resultado incrementado: %d\n", result);
n1 = 5;
result = n1 / n2; // res = 1,66 ~ 2
// Aqui eu quero que o resultado seja 2
printf("Resultado incrementado: %d\n", result);
}
In the first% w / o of%, I need to increment to get the desired result, the second does not. That is, it uses the rules of rounding. What I want is that if there are decimals in the number, it is incremented and not decremented.