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

`float64` is a built-in primitive data type in Go that represents a 64-bit double-precision floating-point number, strictly conforming to the IEEE 754 standard. It is the default type inferred by the Go compiler when a variable is initialized with a floating-point literal.

## Technical Specifications

* **Memory Footprint:** 64 bits (8 bytes).
* **Bit Layout:**
  * Sign: 1 bit
  * Exponent: 11 bits
  * Mantissa (Fraction): 52 bits
* **Precision:** Approximately 15 to 17 decimal digits.

## Syntax and Initialization

Go provides multiple ways to declare and initialize a `float64`, including explicit typing, type inference, and scientific notation.

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

// Explicit declaration
var pi float64 = 3.141592653589793

// Type inference (defaults to float64)
var e = 2.71828

// Scientific notation
var avogadro float64 = 6.022e23
var planck float64 = 6.626e-34
```

## Boundary Limits

The `math` standard library package defines the architectural limits of the `float64` type.

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

import "math"

// Maximum finite float64 value (~1.7976931348623157e+308)
var maxVal float64 = math.MaxFloat64

// Smallest positive, non-zero float64 value (~4.9406564584124654e-324)
var minVal float64 = math.SmallestNonzeroFloat64
```

## Special IEEE 754 Values

Because `float64` adheres to IEEE 754, it supports special states representing undefined or unrepresentable mathematical operations. In Go, constant division by zero is caught by the compiler and results in a compile-time error (`invalid operation: division by zero`). To yield infinity or NaN via arithmetic division, the operands must be variables.

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

import "math"

func evaluateIEEE754() {
    // Positive and Negative Infinity via the math package
    posInf := math.Inf(1)  
    negInf := math.Inf(-1) 

    // Not a Number via the math package
    nan := math.NaN()      

    // Infinity and NaN via variable division
    numerator := 1.0
    zero := 0.0
    calcInf := numerator / zero     // Evaluates to +Inf
    calcNegInf := -numerator / zero // Evaluates to -Inf
    calcNaN := zero / zero          // Evaluates to NaN

    // Evaluation functions
    isInf := math.IsInf(posInf, 0) // returns true
    isNaN := math.IsNaN(nan)       // returns true

    // Prevent "declared and not used" compile-time errors
    _ = posInf
    _ = negInf
    _ = nan
    _ = calcInf
    _ = calcNegInf
    _ = calcNaN
    _ = isInf
    _ = isNaN
}
```

## Type Conversion

Go's strong typing system prohibits implicit type coercion. Operations involving `float64` and other numeric types (including `float32` or integers) require explicit casting. Furthermore, the Go compiler prohibits truncating constant floating-point values directly to integers.

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

func convertTypes() {
    var integerVal int = 42
    var float32Val float32 = 9.81

    // Explicit conversion to float64
    var convertedInt float64 = float64(integerVal)
    var convertedFloat32 float64 = float64(float32Val)

    // Explicit conversion from float64 (truncates decimal portion)
    // Note: int(3.99) causes a compile-time error ("constant 3.99 truncated to integer")
    f := 3.99
    var truncatedInt int = int(f) // Result: 3

    // Prevent "declared and not used" compile-time errors
    _ = convertedInt
    _ = convertedFloat32
    _ = truncatedInt
}
```

## Precision Characteristics

Due to the base-2 representation of floating-point numbers, certain base-10 fractional values cannot be represented exactly. This results in standard floating-point arithmetic rounding errors.

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

func precisionExample() {
    a := 0.1
    b := 0.2
    c := a + b 
    
    // c evaluates to 0.30000000000000004, not exactly 0.3
    
    // Prevent "declared and not used" compile-time error
    _ = c 
}
```

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