Literal

Floating-point literals

Floating constants support decimal and hexadecimal notation. Hexadecimal floating literals require a binary exponent introduced by p or P. Conversion to a floating type can round. Example output: '1.25 2000 3'.

Formal Syntax & Structure

go syntaxgo
1.25; 2e3; 0x1.8p1

Working Example

Example Snippetgo
package main
import "fmt"
func main() {  fmt.Println(1.25, 2e3, 0x1.8p1)}
Go Reference