github.com/richardwilkes/toolbox@v1.121.0/xmath/constants.go (about)

     1  // Copyright (c) 2016-2024 by Richard A. Wilkes. All rights reserved.
     2  //
     3  // This Source Code Form is subject to the terms of the Mozilla Public
     4  // License, version 2.0. If a copy of the MPL was not distributed with
     5  // this file, You can obtain one at http://mozilla.org/MPL/2.0/.
     6  //
     7  // This Source Code Form is "Incompatible With Secondary Licenses", as
     8  // defined by the Mozilla Public License, version 2.0.
     9  
    10  // Package xmath provides math-related utilities.
    11  package xmath
    12  
    13  import (
    14  	"math"
    15  )
    16  
    17  // Mathematical constants. Mostly just re-exported from the math package for convenience.
    18  const (
    19  	E   = math.E
    20  	Pi  = math.Pi
    21  	Phi = math.Phi
    22  
    23  	Sqrt2   = math.Sqrt2
    24  	SqrtE   = math.SqrtE
    25  	SqrtPi  = math.SqrtPi
    26  	SqrtPhi = math.SqrtPhi
    27  
    28  	Ln2    = math.Ln2
    29  	Log2E  = 1 / Ln2
    30  	Ln10   = math.Ln10
    31  	Log10E = 1 / Ln10
    32  )
    33  
    34  // Floating-point limit values. Mostly just re-exported from the math package for convenience. Max is the largest finite
    35  // value representable by the type. SmallestNonzero is the smallest positive, non-zero value representable by the type.
    36  const (
    37  	MaxFloat32             = math.MaxFloat32
    38  	SmallestNonzeroFloat32 = math.SmallestNonzeroFloat32
    39  	MaxFloat64             = math.MaxFloat64
    40  	SmallestNonzeroFloat64 = math.SmallestNonzeroFloat64
    41  )
    42  
    43  // Integer limit values. Mostly just re-exported from the math package for convenience.
    44  const (
    45  	MaxInt    = math.MaxInt
    46  	MinInt    = math.MinInt
    47  	MaxInt8   = math.MaxInt8
    48  	MinInt8   = math.MinInt8
    49  	MaxInt16  = math.MaxInt16
    50  	MinInt16  = math.MinInt16
    51  	MaxInt32  = math.MaxInt32
    52  	MinInt32  = math.MinInt32
    53  	MaxInt64  = math.MaxInt64
    54  	MinInt64  = math.MinInt64
    55  	MaxUint   = math.MaxUint
    56  	MaxUint8  = math.MaxUint8
    57  	MaxUint16 = math.MaxUint16
    58  	MaxUint32 = math.MaxUint32
    59  	MaxUint64 = math.MaxUint64
    60  )
    61  
    62  const (
    63  	// DegreesToRadians converts a value in degrees to radians when multiplied with the value.
    64  	DegreesToRadians = math.Pi / 180
    65  	// RadiansToDegrees converts a value in radians to degrees when multiplied with the value.
    66  	RadiansToDegrees = 180 / math.Pi
    67  )