Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Floating-point based operations

  • No modulo operator
  • No autoincrement and autodecrement
package main

import (
	"fmt"
)

func main() {
	a := 3.0
	b := 7.0

	sum := a + b
	diff := a - b
	div := b / a
	mul := a * b

	fmt.Printf("sum %v\n", sum)
	fmt.Printf("diff %v\n", diff)
	fmt.Printf("mul %v\n", mul)
	fmt.Printf("div %v\n", div)
}
sum 10
diff -4
mul 21
div 2.3333333333333335