Standard library / math/bits

bits.Div32()

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 Div32(hi, lo, y uint32) (quo, rem uint32)

Parameters & Attributes

NameTypeDescription
hiuint32High word of the double-width input.
louint32Low word of the double-width input.
yuint32Second input operand.

Return Value

(quo, rem uint32)

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.Div32(0, 17, 5)  fmt.Println(q, r)}
Go Reference