Documentation ¶
Overview ¶
Copyright (C) 2014 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Float80 type from https://github.com/mewspring/mewmew-l modified a bit to read bytes instead of hex string
Was previously under unlicense/public domain but is under MIT license for fq
Index ¶
- Variables
- func BigIntSetBytesSigned(n *big.Int, buf []byte) *big.Int
- func Clamp[T constraints.Ordered](a, b, v T) T
- func DigitsInBase[T constraints.Integer](n T, basePrefix bool, base int) int
- func PadFormatBigInt(i *big.Int, base int, basePrefix bool, width int) string
- func PadFormatInt[T constraints.Signed](i T, base int, basePrefix bool, width int) string
- func PadFormatUint[T constraints.Unsigned](i T, base int, basePrefix bool, width int) string
- func TwosComplement(nBits int, n uint64) int64
- func ZigZag[U constraints.Unsigned, S constraints.Signed](n U) S
- type BitRange
- type Bits
- type Float16
- type Float80
Constants ¶
This section is empty.
Variables ¶
var BasePrefixMap = map[int]string{
2: "0b",
8: "0o",
16: "0x",
}
var BigIntOne = big.NewInt(1)
Functions ¶
func Clamp ¶
func Clamp[T constraints.Ordered](a, b, v T) T
func DigitsInBase ¶
func DigitsInBase[T constraints.Integer](n T, basePrefix bool, base int) int
func PadFormatBigInt ¶
func PadFormatInt ¶
func PadFormatUint ¶
func TwosComplement ¶
func ZigZag ¶
func ZigZag[U constraints.Unsigned, S constraints.Signed](n U) S
decode zigzag encoded integer https://developers.google.com/protocol-buffers/docs/encoding
Types ¶
type BitRange ¶
func (BitRange) StringByteBits ¶
type Float16 ¶
type Float16 uint16
Float16 represents a 16-bit floating point number, containing a single sign bit, 5 exponent bits and 10 fractional bits. This corresponds to IEEE 754-2008 binary16 (or half precision float) type.
MSB LSB ╔════╦════╤════╤════╤════╤════╦════╤════╤════╤════╤════╤════╤════╤════╤════╤════╗ ║Sign║ E₄ │ E₃ │ E₂ │ E₁ │ E₀ ║ F₉ │ F₈ │ F₇ │ F₆ │ F₅ │ F₄ │ F₃ │ F₂ │ F₁ │ F₀ ║ ╚════╩════╧════╧════╧════╧════╩════╧════╧════╧════╧════╧════╧════╧════╧════╧════╝ Where E is the exponent bits and F is the fractional bits.
func NewFloat16 ¶
NewFloat16 returns a Float16 encoding of a 32-bit floating point number. Infinities and NaNs are encoded as such. Very large and very small numbers get rounded to infinity and zero respectively.
func NewFloat16Inf ¶
Float16Inf returns positive infinity if sign >= 0, negative infinity if sign < 0.
func (Float16) Float32 ¶
Float32 returns the Float16 value expanded to a float32. Infinities and NaNs are expanded as such.
type Float80 ¶
type Float80 struct {
// contains filtered or unexported fields
}
Float80 represents an 80-bit IEEE 754 extended precision floating-point value, in x86 extended precision format.
References:
https://en.wikipedia.org/wiki/Extended_precision#x86_extended_precision_format
func NewFloat80FromBits ¶
NewFloat80FromBits returns a new 80-bit floating-point value based on the sign, exponent and mantissa bits.
func NewFloat80FromBytes ¶
NewFloat80FromBytes returns a new 80-bit floating-point value based on b,
func NewFloat80FromFloat64 ¶
NewFloat80FromFloat64 returns the nearest 80-bit floating-point value for x.
func (Float80) Bits ¶
Bits returns the IEEE 754 binary representation of f, with the sign and exponent in se and the mantissa in m.
func (Float80) Bytes ¶
Bytes returns the x86 extended precision binary representation of f as a byte slice.