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

`int64` is a built-in, statically typed, signed integer data type in Go that occupies exactly 64 bits (8 bytes) of memory, guaranteeing a fixed size regardless of the underlying hardware architecture or operating system.

Unlike the architecture-dependent `int` type, whose size is statically determined at compile time to be either 32 or 64 bits based on the target architecture (`GOARCH`), `int64` provides strict deterministic memory allocation.

## Technical Specifications

* **Memory Footprint:** 64 bits (8 bytes)
* **Encoding:** Two's complement representation
* **Sign Bit:** The Most Significant Bit (MSB) determines the sign (0 for positive, 1 for negative)
* **Minimum Value:** $-2^{63}$ (-9,223,372,036,854,775,808)
* **Maximum Value:** $2^{63}-1$ (9,223,372,036,854,775,807)
* **Zero Value:** `0`

## Syntax and Initialization

You can declare an `int64` using standard variable declaration, short variable declaration with explicit type conversion, or the `new` keyword.

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

import "fmt"

func main() {
    // Standard declaration (initialized to zero value)
    var a int64

    // Declaration with initialization
    var b int64 = 9223372036854775807

    // Short declaration using explicit type conversion
    c := int64(-9223372036854775808)

    // Pointer to an int64
    d := new(int64) 

    fmt.Println(a, b, c, *d)
}
```

## Boundary Constants

The standard library's `math` package provides predefined untyped constants for the absolute boundaries of an `int64`.

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

import (
    "fmt"
    "math"
)

func main() {
    var min int64 = math.MinInt64
    var max int64 = math.MaxInt64

    fmt.Printf("Min: %d, Max: %d\n", min, max)
}
```

## Strict Type Resolution and Conversion

Go's type system does not support implicit type coercion. The compiler treats `int64` as a fundamentally distinct type from `int`, `int32`, or `uint64`, even if the underlying architecture is 64-bit (where `int` and `int64` share the same memory footprint).

Operations mixing `int64` with other numeric types require explicit type conversion.

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

import "fmt"

func main() {
    var archInt int = 42
    var fixedInt int64 = 100

    // INVALID: Mismatched types
    // result := archInt + fixedInt 

    // VALID: Explicit type conversion to int64
    result := int64(archInt) + fixedInt

    // VALID: Explicit type conversion to int
    result2 := archInt + int(fixedInt)
    
    fmt.Println(result, result2)
}
```

## Overflow Behavior

If an arithmetic operation exceeds the maximum or minimum bounds of `int64`, Go silently wraps around using two's complement arithmetic. It does not panic or throw an overflow exception at runtime.

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

import (
    "fmt"
    "math"
)

func main() {
    var max int64 = math.MaxInt64
    fmt.Println(max)     // 9223372036854775807

    // Silent overflow wraps to the minimum value
    overflow := max + 1  
    fmt.Println(overflow) // -9223372036854775808
}
```

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