Standard library / math/bits

bits.Div()

Divides double-width (hi,lo) by y; returns quotient and remainder. Panics if y is zero or y <= hi (quotient overflow). Native uint width is architecture-dependent; local validation uses 64 bits. Expected stdout: '3 2\n'.

Formal Syntax & Structure

go syntaxgo
func Div(hi, lo, y uint) (quo, rem uint)

Parameters & Attributes

NameTypeDescription
hiuintHigh word of the double-width input.
louintLow word of the double-width input.
yuintSecond input operand.

Return Value

(quo, rem uint)

Divides double-width (hi,lo) by y; returns quotient and remainder. Panics if y is zero or y <= hi (quotient overflow). Native uint width is architecture-dependent; local validation uses 64 bits.

Working Example

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