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
| Name | Type | Description |
|---|---|---|
| x | uint64 | First input operand (or sole input if unary). |
| y | uint64 | Second input operand. |
| carry | uint64 | Carry-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)}