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

# Go Division

The `/` operator in Go is a binary arithmetic operator that computes the quotient of two numeric operands. Its specific execution behavior, including precision, truncation, and error handling, is strictly determined by the resolved data types of the operands.

```go theme={"dark"}
quotient := dividend / divisor
```

## Integer Division

When both operands are of an integer type (e.g., `int`, `int64`, `uint8`), the `/` operator performs integer division. The result is always an integer of the same type. Go implements **truncation towards zero**, meaning any fractional component of the mathematical quotient is discarded.

```go theme={"dark"}
var a, b int = 7, 3
var c int = a / b // c == 2

var x, y int = -7, 3
var z int = x / y // z == -2
```

*Note: Attempting integer division by a constant zero (e.g., `x / 0`) results in a compile-time error (`invalid operation: division by zero`). If the divisor is a variable or non-constant expression that evaluates to zero at runtime (e.g., `x / y` where `y == 0`), it triggers a runtime panic.*

## Floating-Point Division

When the operands are of a floating-point type (`float32` or `float64`), the `/` operator performs standard IEEE-754 division, preserving fractional precision.

```go theme={"dark"}
var a, b float64 = 7.0, 3.0
var c float64 = a / b // c == 2.3333333333333335
```

In Go, dividing by a constant zero (e.g., `1.0 / 0.0`) is always a compile-time error, regardless of the numeric type. However, at *runtime*, floating-point division by a variable that evaluates to zero does not trigger a panic. Instead, it yields special IEEE-754 values depending on the signs of both the dividend and the divisor (Go strictly adheres to IEEE-754, which distinguishes between `0.0` and `-0.0`):

```go theme={"dark"}
var pos, neg, zero float64 = 1.0, -1.0, 0.0

// Runtime evaluation of division by zero
var r1 float64 = pos / zero  // +Inf (Positive Infinity: same sign)
var r2 float64 = neg / zero  // -Inf (Negative Infinity: opposite signs)
var r3 float64 = zero / zero // NaN  (Not a Number: both are zero)
```

## Complex Number Division

The operator natively supports complex number types (`complex64` and `complex128`), executing standard algebraic division for complex numbers.

```go theme={"dark"}
var c1, c2 complex128 = complex(2, 4), complex(1, 1)
var c3 complex128 = c1 / c2 // c3 == (3+1i)
```

## Type Constraints

Go's strict typing system mandates that both operands must be of the exact same type. Go does not perform implicit type coercion (widening or narrowing). Dividing an `int` by a `float64` will result in a compile-time type mismatch error unless explicit type conversion is applied.

```go theme={"dark"}
var i int = 5
var f float64 = 2.0

// Invalid: mismatched types int and float64
// result := i / f 

// Valid: explicit conversion
result := float64(i) / f 
```

*Exception: Untyped numeric constants are evaluated at compile-time and will implicitly assume the necessary type required by the expression context, provided the mathematical result does not overflow the target type.*

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