Standard library / math

math.Mod()

Floating-point remainder with quotient truncated toward zero; sign follows dividend. Expected stdout: '-3\n'.

Formal Syntax & Structure

go syntaxgo
func Mod(x, y float64) float64

Parameters & Attributes

NameTypeDescription
xfloat64First input operand (or sole input if unary).
yfloat64Second input operand.

Return Value

float64

Floating-point remainder with quotient truncated toward zero; sign follows dividend.

Working Example

Example Snippetgo
package main
import (  "fmt"  "math")
func main() {  fmt.Println(math.Mod(-7, 4))}
Go Reference