Standard library / math/bits

bits.Add64()

Adds two unsigned words and a carry-in (0 or 1), returning low word and carry-out. Expected stdout: '0 1\n'.

Formal Syntax & Structure

go syntaxgo
func Add64(x, y, carry uint64) (sum, carryOut uint64)

Parameters & Attributes

NameTypeDescription
xuint64First input operand (or sole input if unary).
yuint64Second input operand.
carryuint64Carry-in bit; must be 0 or 1.

Return Value

(sum, carryOut uint64)

Adds two unsigned words and a carry-in (0 or 1), returning low word and carry-out.

Working Example

Example Snippetgo
package main
import (  "fmt"  "math/bits")
func main() {  s, c := bits.Add64(^uint64(0), 1, 0)  fmt.Println(s, c)}
Go Reference