number

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package number contains number types and functions

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Abs

func Abs[T Type](x T) T

Abs gets the absolute value of the Number

func Ceil

func Ceil[F Float](f F) float64

Ceil gets the ceiling value, as float64

func CeilInt

func CeilInt[F Float](f F) int

CeilInt gets the ceiling value, as int

func CommaDecimalString

func CommaDecimalString[F Float](f F, decimalPlaces uint) string

CommaDecimalString returns the Float string, grouped by commas, using N decimal places

func CommaString

func CommaString[I Integer](i I) string

CommaString returns the Integer string, grouped by commas

func DecimalString

func DecimalString[F Float](f F, decimalPlaces uint) string

DecimalString returns the Float string, using N decimal places

func Floor

func Floor[F Float](f F) float64

Floor gets the floor value, as float64

func FloorInt

func FloorInt[F Float](f F) int

FloorInt gets the floor value, as int

func ParseFloat

func ParseFloat(text string) float64

ParseFloat parses the string as float64, default to 0 if invalid float

func ParseInt

func ParseInt(text string) int

ParseInt parses the string as int, default to 0 if invalid int

func ParseUint

func ParseUint(text string) uint

ParseUint parses the string as uint, default to 0 if invalid uint

func Round

func Round[F Float](f F) float64

Round rounds the value to the nearest whole float64

func RoundInt

func RoundInt[F Float](f F) int

RoundInt rounds the value to the nearest int

func RoundToEven

func RoundToEven[F Float](f F) float64

RoundToEven rounds the value to the nearest whole float64, with ties (0.5) rounding to nearest even number

func RoundToEvenInt

func RoundToEvenInt[F Float](f F) int

RoundToEvenInt rounds the value to the nearest int, with ties (0.5) rounding to nearest even number

Types

type Float

type Float interface {
	~float32 | ~float64
}

Float interface unifies the float types

type Int

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

Int interface unifies the Int types

type Integer

type Integer interface {
	Int | Uint
}

Integer interface unifies the integer types

type Type

type Type interface {
	Int | Uint | Float
}

Type interface unifies the number types

type Uint

type Uint interface {
	~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64
}

Uint interface unifies the Uint types

Jump to

Keyboard shortcuts

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