> ## Documentation Index
> Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Kotlin Division Assignment

The `/=` operator is the compound division assignment operator in Kotlin. It divides the left-hand operand by the right-hand operand and assigns the result to the left-hand operand, either by mutating the existing object's internal state or by reassigning the variable reference.

```kotlin theme={"dark"}
a /= b
```

## Operator Resolution Mechanics

Kotlin resolves the `/=` operator through its operator overloading conventions. It does not simply prioritize one function over another; instead, it evaluates the availability of both the `divAssign` and `div` functions. When the compiler encounters `a /= b`, it executes the following resolution sequence:

1. **Ambiguity Check:** The compiler checks if both `divAssign` and `div` are applicable. If `a.divAssign(b)` is valid *and* `a = a.div(b)` is valid (meaning `a` is a `var` and the return type of `div` is assignable to `a`), the compiler reports a compile-time ambiguity error.
2. **`divAssign` Translation:** If only the `divAssign` function is applicable, the operation is translated directly to this mutating function call. The function must return `Unit`.
3. **`div` Translation:** If `divAssign` is not available, but the standard division operator function `div` is applicable and `a` is a `var`, the compiler translates the expression to evaluate `a.div(b)` and reassigns the resulting value back to `a`.

```kotlin theme={"dark"}
// Translation Path 1: Direct mutation via divAssign
a.divAssign(b) 

// Translation Path 2: Reassignment via div
a = a.div(b)
```

## Technical Constraints

* **Mutability and References:** The requirement for the left operand to be a mutable variable (`var`) depends strictly on the resolution path. If the operation resolves to `divAssign`, the left operand can be a read-only reference (`val`) because the function mutates the object's internal state without reassigning the variable reference itself. A `var` is only required if the compiler utilizes the `div` reassignment fallback (`a = a.div(b)`).
* **Type Compatibility:** When the compiler utilizes the `div` fallback, the return type of the `div` function must be a subtype of the declared type of the left operand. For example, dividing an `Int` by a `Double` yields a `Double`; attempting to implicitly reassign this back to an `Int` variable will fail at compile time.
* **Integer Truncation:** If both operands are of standard integer types (e.g., `Byte`, `Short`, `Int`, `Long`), the underlying division operation performs integer division. Any fractional remainder is truncated towards zero before the assignment or mutation occurs.
* **Zero Division:** If the right operand evaluates to `0`, the operator behaves according to the underlying type's division implementation. For integers, this throws an `ArithmeticException`. For floating-point types, it adheres to IEEE 754 standards, resulting in `Infinity` or `NaN`.

<div
  style={{ 
display: "flex", 
justifyContent: "space-between", 
alignItems: "center", 
maxWidth: "754px", 
padding: "1rem 0",
marginBottom: "24px"
}}
>
  <span style={{ fontWeight: "bold", fontSize: "1.25rem", color: "var(--tw-prose-headings)", fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif" }}>Tired of Poor Kotlin Skills? Fix That With Deep Grasping!</span>

  <a
    href="https://syntblaze.com"
    target="_blank"
    style={{ 
  marginLeft: "24px",
  textDecoration: "none", 
  backgroundColor: "#007AFF",
  color: "#ffffff", 
  padding: "6px 16px", 
  borderRadius: "16px",
  fontSize: "0.9rem",
  fontWeight: "600",
  textAlign: "center",
  transition: "background-color 0.2s ease"
}}
  >
    Learn More
  </a>
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/skill-tracking.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=b9b0305c93bb501c9e767b5c76c88835" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/skill-tracking.png" />

  <img src="https://mintcdn.com/syntblazellc/23tyuOzaWS88qFlc/images/nuggets.png?fit=max&auto=format&n=23tyuOzaWS88qFlc&q=85&s=c86c80197299762989e9b882419b2109" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/nuggets.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/bite-sized-exercises.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=a65f9a38c37ff28ab73ed783c53c60e3" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/bite-sized-exercises.png" />
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap", marginTop: "12px" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/mastery-chain.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=748a1763454713e679260fbb95f154a2" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/mastery-chain.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-previews.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=242f61448ff5dd6deaaab2dccc13b507" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-previews.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-explanations.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=cf0fc1c31f9cd0fc26716781be05fbc9" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-explanations.png" />
</div>
