+ 5
When you divide two integers and there is a remainder, does C++ truncate or floor the answer if it is a decimal?
7 Answers
+ 6
Even if it's below zero?
+ 6
-5/2 ?
+ 5
The answer would be automatically floored.
+ 3
I stand corrected, it is better to use the term truncated in both instances (positive and negative). Although in positive integers it does mathematically floor the value, but in negative integers it will truncate the decimal remainder. Thus it is better to use the term truncate.
+ 2
Yes, 1 / 2 would result into a 0.
+ 2
Awesome! Thank you Greg!
+ 2
if your answers are in decimal, then the data type float must be used