mathext

package
v0.2.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 18, 2022 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AbsInt added in v0.1.30

func AbsInt(x int) int

func DimInt added in v0.1.30

func DimInt(x, y int) int

func F32to64

func F32to64(f uint32) uint64

func F32toint32

func F32toint32(x uint32) int32

func F32toint64

func F32toint64(x uint32) int64

func F32touint64

func F32touint64(x float32) uint64

func F64to32

func F64to32(f uint64) uint32

func F64toInt

func F64toInt(f uint64) (val int64, ok bool)

func F64toint32

func F64toint32(x uint64) int32

func F64toint64

func F64toint64(x uint64) int64

func F64touint64

func F64touint64(x float64) uint64

func Fadd32

func Fadd32(x, y uint32) uint32

func Fadd64

func Fadd64(f, g uint64) uint64

func Fcmp64

func Fcmp64(f, g uint64) (cmp int32, isnan bool)

func Fdiv32

func Fdiv32(x, y uint32) uint32

func Fdiv64

func Fdiv64(f, g uint64) uint64

func Feq32

func Feq32(x, y uint32) bool

func Feq64

func Feq64(x, y uint64) bool

func Fge32

func Fge32(x, y uint32) bool

func Fge64

func Fge64(x, y uint64) bool

func Fgt32

func Fgt32(x, y uint32) bool

func Fgt64

func Fgt64(x, y uint64) bool

func Fint32to32

func Fint32to32(x int32) uint32

func Fint32to64

func Fint32to64(x int32) uint64

func Fint64to32

func Fint64to32(x int64) uint32

func Fint64to64

func Fint64to64(x int64) uint64

func Fintto64

func Fintto64(val int64) (f uint64)

func Fmul32

func Fmul32(x, y uint32) uint32

func Fmul64

func Fmul64(f, g uint64) uint64

func Fneg64

func Fneg64(f uint64) uint64

func Fpack32

func Fpack32(sign, mant uint32, exp int, trunc uint32) uint32

func Fpack64

func Fpack64(sign, mant uint64, exp int, trunc uint64) uint64

func Fsub64

func Fsub64(f, g uint64) uint64

func Fuint64to32

func Fuint64to32(x uint64) float32

func Fuint64to64

func Fuint64to64(x uint64) float64

func Funpack32

func Funpack32(f uint32) (sign, mant uint32, exp int, inf, nan bool)

func Funpack64

func Funpack64(f uint64) (sign, mant uint64, exp int, inf, nan bool)

func IsAlmostEqualFloat32

func IsAlmostEqualFloat32(a, b float32) bool

func IsAlmostEqualFloat64

func IsAlmostEqualFloat64(a, b float64) bool

Returns true if this number is at most kMaxUlps ULP's away from rhs. In particular, this function:

  • returns false if either number is (or both are) NAN.
  • treats really large numbers as almost equal to infinity.
  • thinks +0.0 and -0.0 are 0 DLP's apart.

func MaxInt added in v0.1.30

func MaxInt(x, y int) int

func MinInt added in v0.1.30

func MinInt(x, y int) int

func RandFloat

func RandFloat(min, max float64) float64

Random number in [min, max]

func RandInt

func RandInt(min, max int) int

Random integer in [min, max]

func RangePerm

func RangePerm(min, max int) []int

集合内随机取数, [min,max]

func RoundHalf

func RoundHalf(v float64) int

四舍五入

func SafeDiv added in v0.1.30

func SafeDiv(x, y float64) float64

func SafeDivInt added in v0.1.30

func SafeDivInt(x, y int) int

func SignAndMagnitudeToBiasedFloat32

func SignAndMagnitudeToBiasedFloat32(sam uint32) uint32

func SignAndMagnitudeToBiasedFloat64

func SignAndMagnitudeToBiasedFloat64(sam uint64) uint64

Converts an integer from the sign-and-magnitude representation to the biased representation. More precisely, let N be 2 to the power of (kBitCount - 1), an integer x is represented by the unsigned number x + N.

For instance,

-N + 1 (the most negative number representable using
       sign-and-magnitude) is represented by 1;
0      is represented by N; and
N - 1  (the biggest number representable using
       sign-and-magnitude) is represented by 2N - 1.

Read http://en.wikipedia.org/wiki/Signed_number_representations for more details on signed number representations.

Types

type LCG

type LCG struct {
	// contains filtered or unexported fields
}

线性同余法的随机数生成器 see https://en.wikipedia.org/wiki/Linear_congruential_generator

func (*LCG) Rand

func (g *LCG) Rand() uint32

func (*LCG) Seed

func (g *LCG) Seed(seed uint32)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL