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

`complex64` is a built-in numeric data type in Go that represents a complex number using 64 bits of memory. It is composed of two 32-bit floating-point numbers (`float32`): one representing the real component and the other representing the imaginary component. Both underlying components adhere to the IEEE 754 standard for floating-point arithmetic.

## Memory Layout

* **Total Size:** 8 bytes (64 bits)
* **Real Part:** 4 bytes (`float32`)
* **Imaginary Part:** 4 bytes (`float32`)

## Declaration and Initialization

You can initialize a `complex64` variable using the built-in `complex()` function or by using complex literal syntax with the `i` suffix.

Because Go's untyped complex literals default to `complex128`, you must explicitly declare the type when creating a `complex64` using shorthand syntax.

```go theme={"dark"}
// Method 1: Using the built-in complex() function.
// The untyped floating-point constants yield an untyped complex constant,
// which is implicitly converted to complex64 by the variable assignment context.
var c1 complex64 = complex(2.5, 3.1)

// Method 2: Using literal notation with explicit type declaration.
var c2 complex64 = 2.5 + 3.1i

// Method 3: Using short variable declaration with type conversion.
c3 := complex64(2.5 + 3.1i)
```

## Component Extraction

Go provides two built-in functions, `real()` and `imag()`, to extract the respective components of a complex number. When applied to a `complex64` value, both functions return a `float32`.

```go theme={"dark"}
var c complex64 = 4.2 - 1.5i

// Extracting the real component
var r float32 = real(c) // r == 4.2

// Extracting the imaginary component
var im float32 = imag(c) // im == -1.5
```

## Arithmetic and Comparison Operations

`complex64` supports standard arithmetic operators. Operations are performed on both the real and imaginary parts simultaneously according to the mathematical rules of complex arithmetic.

```go theme={"dark"}
a := complex64(1.0 + 2.0i)
b := complex64(3.0 + 4.0i)

sum := a + b        // 4.0 + 6.0i
difference := a - b // -2.0 - 2.0i
product := a * b    // -5.0 + 10.0i
quotient := a / b   // 0.44 + 0.08i
```

You can compare `complex64` values using equality operators (`==` and `!=`). Two `complex64` values are strictly equal if and only if both their real and imaginary `float32` components are exactly equal. Inequality operators (`<`, `<=`, `>`, `>=`) are not defined for complex types in Go.

## Standard Library Compatibility

The Go standard library's `math/cmplx` package exclusively operates on `complex128` values. To perform advanced mathematical operations (such as calculating the absolute value or square root) on a `complex64` variable, you must explicitly convert it to `complex128` before passing it to the function.

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

import (
    "fmt"
    "math/cmplx"
)

func main() {
    var c complex64 = 3.0 + 4.0i

    // Explicit conversion to complex128 is required for math/cmplx functions.
    // The result is cast back to float32 to match the precision of complex64.
    magnitude := float32(cmplx.Abs(complex128(c))) 
    
    fmt.Println(magnitude) // Output: 5
}
```

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