Standard library / math/bits

bits.Div64()

Divides double-width (hi,lo) by y; returns quotient and remainder. Panics if y is zero or y <= hi (quotient overflow). Expected stdout: '3 2\n'.

Formal Syntax & Structure

go syntaxgo
func Div64(hi, lo, y uint64) (quo, rem uint64)

Parameters & Attributes

NameTypeDescription
hiuint64High word of the double-width input.
louint64Low word of the double-width input.
yuint64Second input operand.

Return Value

(quo, rem uint64)

Divides double-width (hi,lo) by y; returns quotient and remainder. Panics if y is zero or y <= hi (quotient overflow).

Working Example

Example Snippetgo
package main
import (  "fmt"  "math/bits")
func main() {  q, r := bits.Div64(0, 17, 5)  fmt.Println(q, r)}
Go Reference