Documentation ¶
Overview ¶
Copyright 2018 Weborama. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
Copyright 2018 Weborama. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
Index ¶
- func Cmp(x, y Uint128) int
- func IsZero(x Uint128) bool
- func LeadingZeros(x Uint128) int
- func Len(x Uint128) int
- func OnesCount(x Uint128) int
- func TrailingZeros(x Uint128) int
- type Uint128
- func Add(x, y Uint128) Uint128
- func Add128(x, y, carry Uint128) (sum, carryOut Uint128)
- func And(x, y Uint128) Uint128
- func AndNot(x, y Uint128) Uint128
- func Decr(x Uint128) Uint128
- func Incr(x Uint128) Uint128
- func MaxUint128() Uint128
- func NewFromString(str string) (x Uint128, err error)
- func Not(x Uint128) Uint128
- func Or(x, y Uint128) Uint128
- func Reverse(x Uint128) (y Uint128)
- func ReverseBytes(x Uint128) (y Uint128)
- func ShiftLeft(x Uint128, bits uint) Uint128
- func ShiftRight(x Uint128, bits uint) Uint128
- func Sub(x, y Uint128) Uint128
- func Xor(x, y Uint128) Uint128
- func Zero() Uint128
- func (x Uint128) Add(y Uint128) Uint128
- func (x Uint128) Add128(y, carry Uint128) (sum, carryOut Uint128)
- func (x Uint128) And(y Uint128) Uint128
- func (x Uint128) AndNot(y Uint128) Uint128
- func (x Uint128) Cmp(y Uint128) int
- func (x Uint128) Decr() Uint128
- func (x Uint128) Format(fmtState fmt.State, c rune)
- func (x Uint128) HexString() string
- func (x Uint128) Incr() Uint128
- func (x Uint128) IsZero() bool
- func (x Uint128) Not() Uint128
- func (x Uint128) Or(y Uint128) Uint128
- func (x Uint128) ShiftLeft(bits uint) Uint128
- func (x Uint128) ShiftRight(bits uint) Uint128
- func (x Uint128) String() string
- func (x Uint128) Sub(y Uint128) Uint128
- func (x Uint128) Xor(y Uint128) Uint128
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Cmp ¶
Cmp compares two Uint128 and returns one of the following values:
-1 if x < y 0 if x == y +1 if x > y
nolint: varnamelen
func LeadingZeros ¶
LeadingZeros returns the number of leading zero bits in x; the result is 128 for x == 0.
func Len ¶
Len returns the minimum number of bits required to represent x; the result is 0 for x == 0.
func TrailingZeros ¶
TrailingZeros returns the number of trailing zero bits in x; the result is 128 for x == 0.
Types ¶
type Uint128 ¶
type Uint128 struct {
H, L uint64
}
Uint128 defines an unsigned integer of 128 bits.
func Add128 ¶ added in v0.7.1
Add128 returns the sum with carry of x, y and carry: sum = x + y + carry. The carry input must be 0 or 1; otherwise the behavior is undefined. The carryOut output is guaranteed to be 0 or 1.
func NewFromString ¶
NewFromString creates a new Uint128 from its hexadecimal string representation. XXX: Do a proper job of it.
func ReverseBytes ¶
ReverseBytes returns the value of x with its bytes in reversed order.
func ShiftRight ¶
ShiftRight shifts x to the right by the provided number of bits. nolint: varnamelen
func (Uint128) Add128 ¶ added in v0.7.1
Add128 returns the sum with carry of x, y and carry: sum = x + y + carry. The carry input must be 0 or 1; otherwise the behavior is undefined. The carryOut output is guaranteed to be 0 or 1.
func (Uint128) Cmp ¶
Cmp compares two Uint128 and returns one of the following values:
-1 if x < y 0 if x == y +1 if x > y
func (Uint128) HexString ¶
HexString returns a Hexadecimal string representation of an Uint128. XXX: Do a proper job of it.
func (Uint128) ShiftRight ¶
ShiftRight shifts x to the right by the provided number of bits.