Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

golang

What is type complex64 in Golang?

Abdul Monum

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Variables contain data, and data can be of different data types, or types for short. Golang is a statically typed language; this means the compiler must know the types of all the variables, either because they were explicitly indicated or because the compiler can infer the type from the code context. A type defines the set of values and the set of operations that can take place on those values.

Type complex64 in Golang is the set of all complex numbers with float32 real and float32 imaginary parts. Below is how you declare a variable of type complex64:

var var_name complex64 = complex(a,b)

Example

package main
import "fmt"
func main() {
var var1 complex64 = complex(3,-5)
var var2 complex64 = complex(2, 7.5)
fmt.Println("var1:", var1)
fmt.Printf("Type of var1: %T", var1)
fmt.Println("\nvar2:", var2)
fmt.Printf("Type of var2: %T", var2)
}

Explanation

The above code declares the variables var1 and var2 with type complex64, and displays the variables and their type using the Println and Printf method respectively.

RELATED TAGS

golang

CONTRIBUTOR

Abdul Monum
Copyright ©2022 Educative, Inc. All rights reserved

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring