fix32

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: May 28, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Shift        int32 = 16
	FractionMask int32 = (1 << Shift) - 1
	IntegerMask        = ^FractionMask
)
View Source
const (
	Zero   int32 = 0
	Neg1   int32 = -1 << Shift
	One    int32 = 1 << Shift
	Two    int32 = 2 << Shift
	Three  int32 = 3 << Shift
	Four   int32 = 4 << Shift
	Half         = One >> 1
	Pi           = int32(13493037705 >> 16) // (int32)(Math.PI * 65536.0) << 16
	Pi2          = int32(26986075409 >> 16)
	PiHalf       = int32(6746518852 >> 16)
	E            = int32(11674931555 >> 16)
)

Constants

View Source
const (
	MinValue int32 = -2147483648
	MaxValue int32 = 2147483647
)
View Source
const (
	RcpLn2         = int32(0x171547652 >> 16) // 1.0 / log(2.0) ~= 1.4426950408889634
	RcpLog2E       = int32(2977044471 >> 16)  // 1.0 / log2(e) ~= 0.6931471805599453
	RcpTwoPi int32 = 683565276                // 1.0 / (4.0 * 0.5 * pi);  -- the 4.0 factor converts directly to s2.30
)

Private constants

Variables

This section is empty.

Functions

func Abs

func Abs(v int32) int32

Abs Returns the absolute (positive) value of v.

func Acos

func Acos(x int32) int32

func AcosFast

func AcosFast(x int32) int32

func AcosFastest

func AcosFastest(x int32) int32

func Add

func Add(a, b int32) int32

Add Adds the two FP numbers together.

func Asin

func Asin(x int32) int32

func AsinFast

func AsinFast(x int32) int32

func AsinFastest

func AsinFastest(x int32) int32

func Atan

func Atan(x int32) int32

func Atan2

func Atan2(y, x int32) int32

func Atan2Div

func Atan2Div(y, x int32) int32

func Atan2DivFast

func Atan2DivFast(y, x int32) int32

func Atan2DivFastest

func Atan2DivFastest(y, x int32) int32

func Atan2Fast

func Atan2Fast(y, x int32) int32

func Atan2Fastest

func Atan2Fastest(y, x int32) int32

func AtanFast

func AtanFast(x int32) int32

func AtanFastest

func AtanFastest(x int32) int32

func Ceil

func Ceil(v int32) int32

Ceil Round up to nearest integer.

func CeilToInt

func CeilToInt(v int32) int32

CeilToInt Converts a fixed-point value into an integer by rounding it up to nearest integer.

func Clamp

func Clamp(a, min, max int32) int32

Clamp Returns the value clamped between min and max.

func Cos

func Cos(x int32) int32

func CosFast

func CosFast(x int32) int32

func CosFastest

func CosFastest(x int32) int32

func Div

func Div(a, b int32) int32

Div Calculates division approximation.

func DivFast

func DivFast(a, b int32) int32

DivFast Calculates division approximation.

func DivFastest

func DivFastest(a, b int32) int32

DivFastest Calculates division approximation.

func DivPrecise

func DivPrecise(a, b int32) int32

DivPrecise Divides two FP values.

func Exp

func Exp(x int32) int32

func Exp2

func Exp2(x int32) int32

Exp2 Calculates the base 2 exponent.

func Exp2Fast

func Exp2Fast(x int32) int32

Exp2Fast Calculates the base 2 exponent.

func Exp2Fastest

func Exp2Fastest(x int32) int32

Exp2Fastest Calculates the base 2 exponent.

func ExpFast

func ExpFast(x int32) int32

func ExpFastest

func ExpFastest(x int32) int32

func Floor

func Floor(v int32) int32

Floor Round down to nearest integer.

func FloorToInt

func FloorToInt(v int32) int32

FloorToInt Converts a fixed-point value into an integer by rounding it down to nearest integer.

func Fract

func Fract(v int32) int32

Fract Returns the fractional part of x. Equal to 'x - floor(x)'.

func FromFloat32

func FromFloat32(v float32) int32

FromFloat32 Converts a float32 to a fp-point value.

func FromFloat64

func FromFloat64(v float64) int32

FromFloat64 Converts a float64 to a fp-point value.

func FromInt32

func FromInt32(v int32) int32

FromInt32 Converts an integer to a fp-point value.

func Lerp

func Lerp(a, b, t int32) int32

Lerp Linearly interpolate from a to b by t.

func Log

func Log(x int32) int32

func Log2

func Log2(x int32) int32

func Log2Fast

func Log2Fast(x int32) int32

func Log2Fastest

func Log2Fastest(x int32) int32

func LogFast

func LogFast(x int32) int32

func LogFastest

func LogFastest(x int32) int32

func Max

func Max(a, b int32) int32

Max Returns the maximum of the two values.

func Min

func Min(a, b int32) int32

Min Returns the minimum of the two values.

func Mod

func Mod(a, b int32) int32

Mod Divides two FP values and returns the modulus.

func Mul

func Mul(a, b int32) int32

Mul Multiplies two FP values together.

func Nabs

func Nabs(v int32) int32

Nabs Negative absolute value (returns -abs(x)).

func Nlz

func Nlz(v uint32) int32

func Pow

func Pow(x, exponent int32) int32

Pow Calculates x to the power of the exponent.

func PowFast

func PowFast(x, exponent int32) int32

PowFast Calculates x to the power of the exponent.

func PowFastest

func PowFastest(x, exponent int32) int32

PowFastest Calculates x to the power of the exponent.

func RSqrt

func RSqrt(x int32) int32

RSqrt Calculates the reciprocal square root.

func RSqrtFast

func RSqrtFast(x int32) int32

RSqrtFast Calculates the reciprocal square root.

func RSqrtFastest

func RSqrtFastest(x int32) int32

RSqrtFastest Calculates the reciprocal square root.

func Rcp

func Rcp(x int32) int32

Rcp Calculates reciprocal approximation.

func RcpFast

func RcpFast(x int32) int32

RcpFast Calculates reciprocal approximation.

func RcpFastest

func RcpFastest(x int32) int32

RcpFastest Calculates reciprocal approximation.

func Round

func Round(v int32) int32

Round to nearest integer.

func RoundToInt

func RoundToInt(v int32) int32

RoundToInt Converts a fixed-point value into an integer by rounding it to nearest integer.

func Sign

func Sign(v int32) int32

Sign Returns the sign of the value (-1 if negative, 0 if zero, 1 if positive).

func Sin

func Sin(x int32) int32

func SinFast

func SinFast(x int32) int32

func SinFastest

func SinFastest(x int32) int32

func Sqrt

func Sqrt(x int32) int32

func SqrtFast

func SqrtFast(x int32) int32

func SqrtFastest

func SqrtFastest(x int32) int32

func SqrtPrecise

func SqrtPrecise(a int32) int32

SqrtPrecise Calculates the square root of the given number.

func Sub

func Sub(a, b int32) int32

Sub Subtracts the two FP numbers from each other.

func Tan

func Tan(x int32) int32

func TanFast

func TanFast(x int32) int32

func TanFastest

func TanFastest(x int32) int32

func ToFloat32

func ToFloat32(v int32) float32

ToFloat32 Converts a FP value into a float.

func ToFloat64

func ToFloat64(v int32) float64

ToFloat64 Converts a fixed-point value into a double.

func ToString

func ToString(v int32) string

ToString Converts the value to a human readable string.

func UnitSin

func UnitSin(z int32) int32

func UnitSinFast

func UnitSinFast(z int32) int32

func UnitSinFastest

func UnitSinFastest(z int32) int32

Types

This section is empty.

Jump to

Keyboard shortcuts

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