Documentation ¶
Overview ¶
Package mathlib implements some functions for math calculation.
Index ¶
- Constants
- func Abs[T Numeric](n T) T
- func Average[T Numeric](numbers ...T) T
- func BDToGCJ(lat, lng float64) (float64, float64)
- func Ceil[T Numeric](a, b T) T
- func Distance(lngA, latA, lngB, latB float64) float64
- func DistanceI[T constraints.Integer](lngA, latA, lngB, latB int64) T
- func Floor[T Numeric](a, b T) T
- func InRange[T constraints.Ordered](val, min, max T) bool
- func Max[T constraints.Ordered](i T, n ...T) T
- func Min[T constraints.Ordered](i T, n ...T) T
- func OutRange[T constraints.Ordered](val, min, max T) bool
- func Percent[T Numeric](a, b T) float64
- func Round[T Numeric](a, b T) T
- func SafePage[T constraints.Integer](i T) T
- func Sum[T Numeric](n []T, missing T) T
- func ToString[T constraints.Integer](input T) string
- type Numeric
Constants ¶
View Source
const R = 6367000
R 地球半径,单位米
Variables ¶
This section is empty.
Functions ¶
func DistanceI ¶
func DistanceI[T constraints.Integer](lngA, latA, lngB, latB int64) T
func InRange ¶
func InRange[T constraints.Ordered](val, min, max T) bool
InRange check if val in int/float range [min, max]
func Max ¶
func Max[T constraints.Ordered](i T, n ...T) T
func Min ¶
func Min[T constraints.Ordered](i T, n ...T) T
func OutRange ¶
func OutRange[T constraints.Ordered](val, min, max T) bool
OutRange check if val not in int/float range [min, max]
func SafePage ¶
func SafePage[T constraints.Integer](i T) T
func ToString ¶ added in v1.0.6
func ToString[T constraints.Integer](input T) string
ToString convert a integer to string with base 10
Types ¶
type Numeric ¶
type Numeric interface { constraints.Integer | constraints.Float }
Click to show internal directories.
Click to hide internal directories.