Standard library / math/bits
bits.Sub64()
Subtracts y and borrow-in (0 or 1) from x; returns low word and borrow-out. Expected stdout: 'true 1\n'.
Formal Syntax & Structure
go syntaxgo
func Sub64(x, y, borrow uint64) (diff, borrowOut uint64)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| x | uint64 | First input operand (or sole input if unary). |
| y | uint64 | Second input operand. |
| borrow | uint64 | Borrow-in bit; must be 0 or 1. |
Return Value
(diff, borrowOut uint64)
Subtracts y and borrow-in (0 or 1) from x; returns low word and borrow-out.
Working Example
Example Snippetgo
package main
import ( "fmt" "math/bits")
func main() { s, c := bits.Sub64(0, 1, 0) fmt.Println(s == ^uint64(0), c)}