> ## 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.

# C Multiplication Assignment

The `*=` (multiplication assignment) operator is a compound assignment operator in C that multiplies the current value of a modifiable lvalue by the value of the right operand, storing the computed product back into the left operand.

```c theme={"dark"}
lvalue *= expression;
```

## Semantic Equivalence

The expression `E1 *= E2` is semantically equivalent to `E1 = E1 * (E2)`, with two critical architectural distinctions:

1. **Single Evaluation:** The left operand (`E1`) is evaluated exactly once. This is crucial when the left operand contains side effects, such as function calls or increment/decrement operators. For example, `arr[i++] *= 2 + 3;` increments `i` only once and correctly multiplies the array element by 5, whereas `arr[i++] = arr[i++] * (2 + 3);` invokes undefined behavior due to unsequenced modifications of `i`.
2. **Atomic Operations (C11):** If `E1` has an `_Atomic`-qualified type, the compound assignment `*=` guarantees an indivisible read-modify-write operation. The expanded form `E1 = E1 * (E2)` does not, as it executes as separate, non-atomic read and write operations.

The parentheses around `E2` in the expanded form are mandatory to preserve operator precedence.

## Operand Constraints

* **Left Operand (`lvalue`):** Must be a modifiable lvalue of an arithmetic type (integer or floating-point). It cannot be a pointer, an array designator, or a `const`-qualified variable.
* **Right Operand (`expression`):** Must evaluate to an arithmetic type. It does not need to be an lvalue.

## Type Conversion and Promotion

The `*=` operator enforces a strict sequence of implicit type conversions:

1. **Usual Arithmetic Conversions:** Before multiplication, the compiler applies the usual arithmetic conversions to both operands to establish a common type for the arithmetic operation. If one operand has a floating-point type, the other is converted directly to that floating-point type. Integer promotions are only performed as a sub-step of these conversions if neither operand has a floating-point type. If signed integer overflow occurs during this arithmetic multiplication step, it results in undefined behavior.
2. **Assignment Conversion:** After the product is calculated in the common type, the result is implicitly converted back to the declared type of the left operand before assignment.

If the left operand is of a narrower type or lower precision than the calculated product, this final assignment conversion may result in truncation or loss of precision. If the value cannot be represented by the left operand's type, the behavior depends on the types involved: an out-of-range conversion to a signed integer type results in implementation-defined behavior (or an implementation-defined signal), whereas an out-of-range conversion from a floating-point type to any integer type results in undefined behavior.

```c theme={"dark"}
#include <stdint.h>

int main(void) {
    // Syntax visualization of type coercion mechanics
    int8_t a = 10;
    float  b = 2.5f;

    a *= b; 
    // 1. 'a' is converted directly to 'float' (no integer promotion occurs).
    // 2. 10.0f * (2.5f) is evaluated (yields float 25.0f).
    // 3. 25.0f is converted back to int8_t.
    // 4. The value 25 is stored in 'a'.
    
    return 0;
}
```

## Evaluation Order and Result

The sequencing rules of C dictate that the value computation of the right operand is sequenced before the assignment to the left operand.

The result of the entire `*=` expression is the updated value of the left operand after the assignment has taken place. The type of the result is the unqualified type of the left operand.

In C, the result of any assignment expression is an **rvalue** (unlike C++, where it yields an lvalue). Because the left operand of an assignment must be a modifiable lvalue, an expression like `(a *= b) = c;` results in a constraint violation during semantic analysis. While syntactically valid according to the language grammar (`unary-expression assignment-operator assignment-expression`), it is semantically invalid because the rvalue yielded by `a *= b` inherently cannot be the target of an assignment.

<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 C 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>
