numhelper

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AlignDown added in v0.12.0

func AlignDown[T UI](n, alignment T) T

func AlignUp added in v0.12.0

func AlignUp[T UI](n, alignment T) T

func ParseFloat

func ParseFloat[T Float](i any) (T, error)

func ParseInteger

func ParseInteger[T Integer](i any) (T, error)

func ParseIntegers

func ParseIntegers[T Integer, V any](arr []V) (ret []T, err error)

func ParseNumber

func ParseNumber(i any) (_ uint64, isFloat bool, _ error)

ParseNumber converts i to uint64 (with sign kept)

if i is a float number (indicated by return value isFloat), return IEEE 754 bits of i

func ParseString added in v0.12.0

func ParseString(str string, assumeFloat bool) (uint64, bool, error)

ParseString parses a number in string, it may be a float

func ParstFloats

func ParstFloats[T Float, V any](arr []V) (ret []T, err error)

Types

type Float

type Float interface {
	~float32 | ~float64
}

type Integer

type Integer interface {
	SI | UI
}

Integer for both signed and unsigned integers

type Number added in v0.12.0

type Number interface {
	Real | ~complex64 | ~complex128
}

type Real added in v0.12.0

type Real interface {
	Integer | Float
}

type SI added in v0.12.0

type SI interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64
}

SI signed integer types

type UI added in v0.12.0

type UI interface {
	~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
}

UI unsigned integer types

Jump to

Keyboard shortcuts

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