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

`int16` is a built-in primitive data type in Go representing a signed 16-bit integer. It allocates exactly 2 bytes of memory and encodes values using two's complement binary representation.

## Technical Specifications

* **Size:** 16 bits (2 bytes)
* **Minimum Value:** -32,768 ($-2^{15}$)
* **Maximum Value:** 32,767 ($2^{15}-1$)
* **Zero Value:** `0`

The `math` package provides exported constants for the boundary values of `int16`:

```go theme={"dark"}
import "math"

const min int16 = math.MinInt16 // -32768
const max int16 = math.MaxInt16 // 32767
```

## Declaration and Initialization

Variables of type `int16` can be declared using standard Go variable declaration syntax. If no value is assigned, it defaults to its zero value.

```go theme={"dark"}
// Explicit declaration with initialization
var x int16 = 15000

// Declaration relying on the zero value (0)
var y int16

// Short variable declaration with explicit type conversion
z := int16(-1024)
```

## Strict Typing and Conversion

Go's type system is strictly enforced. An `int16` is a distinct type from `int`, `int8`, `int32`, `int64`, and `uint16`. Implicit type promotion or demotion is not supported. You must perform explicit type conversions when performing operations between `int16` and other numeric types.

```go theme={"dark"}
var a int16 = 500
var b int32 = 1000

// Invalid: mismatched types int16 and int32
// result := a + b 

// Valid: explicit conversion to a common type
result := int32(a) + b 
```

## Overflow and Wraparound Behavior

Because `int16` has a fixed memory footprint, operations that exceed its maximum or minimum bounds result in an integer overflow. How Go handles this depends on whether the overflow occurs at runtime or compile time.

At **runtime**, Go handles overflow via silent wraparound based on two's complement arithmetic. Incrementing past the maximum value wraps around to the minimum value, and decrementing below the minimum wraps to the maximum.

```go theme={"dark"}
package main

import "fmt"

func main() {
	var maxVal int16 = 32767 // math.MaxInt16
	
	// Incrementing past the maximum value wraps around to the minimum value
	maxVal++ 
	fmt.Println(maxVal) // Output: -32768

	var minVal int16 = -32768 // math.MinInt16
	
	// Decrementing below the minimum value wraps around to the maximum value
	minVal--
	fmt.Println(minVal) // Output: 32767
}
```

At **compile time**, Go strictly catches overflows in constant expressions. If an operation on constants exceeds the `int16` bounds, the compiler throws an error rather than silently wrapping around.

```go theme={"dark"}
package main

// Valid: within bounds
const a int16 = 32767 

// Invalid: constant 32768 overflows int16
// const b int16 = 32767 + 1 
```

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