Bird
0
0

Why does Kotlin integer division truncate the decimal part instead of rounding?

hard📝 Conceptual Q10 of 15
Kotlin - Operators and Expressions
Why does Kotlin integer division truncate the decimal part instead of rounding?
ABecause integer division returns the quotient without remainder
BBecause Kotlin throws an error on decimals
CBecause Kotlin converts integers to floats automatically
DBecause Kotlin always rounds down integers
Step-by-Step Solution
Solution:
  1. Step 1: Understand integer division behavior

    Integer division returns the quotient part only, ignoring remainder or decimals.
  2. Step 2: Clarify why truncation happens

    It truncates because it returns the whole number result of division without rounding.
  3. Final Answer:

    Because integer division returns the quotient without remainder -> Option A
  4. Quick Check:

    Integer division = quotient only, no rounding [OK]
Quick Trick: Integer division drops decimals, no rounding [OK]
Common Mistakes:
MISTAKES
  • Thinking it rounds
  • Assuming automatic float conversion
  • Expecting errors on decimals

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kotlin Quizzes