Documentation ¶
Index ¶
- Constants
- Variables
- func AddSS(inReal0, inReal1 []float64) []float64
- func AddSV(inReal []float64, v float64) []float64
- func Avg(inReal []float64, timePeriod int) []float64
- func BaseConvert(num string, fromBase, toBase int) (string, error)
- func BigIntToFloat64(it *big.Int) float64
- func BiggerEqualThan(left, right *big.Int) bool
- func BiggerThan(left, right *big.Int) bool
- func BoundUint32(min, toBound, max uint32) uint32
- func CmpInt64Array(a, b []int64) bool
- func ContainsInt(src []int, toFind int) bool
- func DetectMaxPrec(vals []ElegantFloat, humanReadPrec int) int
- func DetectMaxPrecRaw(vals []float64, humanReadPrec int) int
- func DetectPrecByHumanReadPrec(val float64, humanReadPrec int) int
- func ElegantFloatArrayToFloatArray(in []ElegantFloat) []float64
- func Fibonacci(n int) int
- func Float64ToByte(f float64) []byte
- func Float64ToByteLE(f float64) []byte
- func FloatAlmostEqual(a, b float64) bool
- func FloatsEqual(a, b []float64) bool
- func FloatsPtrToFloats(in []*float64) []float64
- func FloatsToFloatsPtr(in []float64) []*float64
- func Format(num interface{}, base int) (string, error)
- func FormatFloat64(f float64, prec int) string
- func FormatInt(i int) string
- func FormatInt64(i int64) string
- func FormatUint16(u uint16) string
- func FormatUint32(u uint32) string
- func FormatUint64(u uint64) string
- func FormatUint8(u uint8) string
- func GetLast1(v int) int
- func GetLast2(v int) int
- func IsDigit(s string) bool
- func IsEvenInt64(n int64) bool
- func IsEvenUint64(n uint64) bool
- func IsOddInt64(n int64) bool
- func IsOddUint64(n uint64) bool
- func IsZero(val *big.Int) bool
- func JoinFormatInt(sep string, num ...int) string
- func MaxFloat(args ...float64) float64
- func MaxFloat64(first float64, args ...float64) float64
- func MaxInt(first int, args ...int) int
- func MaxInt64(first int64, args ...int64) int64
- func MaxSS(inReal0, inReal1 []float64) []float64
- func MaxSV(inReal []float64, inTimePeriod int) []float64
- func MaxUint32(first uint32, args ...uint32) uint32
- func MaxUint64(first uint64, args ...uint64) uint64
- func Mean(values []float64) float64
- func MinFloat(args ...float64) float64
- func MinFloat64(first float64, args ...float64) float64
- func MinInt(first int, args ...int) int
- func MinInt64(first int64, args ...int64) int64
- func MinSS(inReal0, inReal1 []float64) []float64
- func MinSV(inReal []float64, inTimePeriod int) []float64
- func MinUint32(first uint32, args ...uint32) uint32
- func MinUint64(first uint64, args ...uint64) uint64
- func MinUintArray(args []uint) uint
- func MulSS(inReal0, inReal1 []float64) []float64
- func MulSV(inReal []float64, v float64) []float64
- func ParseBigInt(num string, base int) (big.Int, error)
- func ParseFloat64(s string) (float64, error)
- func RealGoldenRatio() float64
- func RemoveDuplicate(elements []int) []int
- func RemoveLast1(v int) int
- func RemoveLast2(v int) int
- func RemoveUint(src []uint, toRemove uint, removeCount int) []uint
- func ReverseBigFloats(in []big.Float)
- func ReverseBigInts(in []big.Int)
- func ReverseFloats(in []float64)
- func ReverseInt64s(in []int64)
- func ReverseInts(in []int)
- func ReverseUints(in []uint)
- func SetHead0(inReal []float64, count int)
- func Slice(v int64, begin, len int) (int64, error)
- func SmallerEqualThan(left, right *big.Int) bool
- func SmallerThan(left, right *big.Int) bool
- func SortBigFloats(in []big.Float)
- func SortBigInts(in []big.Int)
- func SortFloats(in []float64)
- func SortInt64s(in []int64)
- func SortInts(in []int)
- func SortUints(in []uint)
- func Std(values []float64, ddof int) float64
- func SubSS(inReal0, inReal1 []float64) []float64
- func SubSV(inReal []float64, v float64) []float64
- func Sum(values []float64) float64
- func SumFloat(args ...float64) float64
- func ToString(x interface{}) string
- type ElegantFloat
- func NewElegantFloat(val float64, prec int) ElegantFloat
- func NewElegantFloatArray(vals []float64, prec int) []ElegantFloat
- func NewElegantFloatPtrArray(vals []*float64, prec int) []*ElegantFloat
- func NewElegantFloatPtrArray2(vals []float64, prec int) []*ElegantFloat
- func NewElegantFloatPtrArray3(vals []float64, prec int, nilVal float64) []*ElegantFloat
- func (t *ElegantFloat) JSON(fmtNaNasNull bool) ([]byte, error)
- func (t ElegantFloat) MarshalJSON() ([]byte, error)
- func (t *ElegantFloat) Raw() float64
- func (t *ElegantFloat) SetHumanReadPrec(humanReadPrec int)
- func (t *ElegantFloat) SetPrec(prec int)
- func (t *ElegantFloat) String() string
- func (t *ElegantFloat) UnmarshalJSON(b []byte) error
Constants ¶
const ( Billion = 1000000000 Million = 1000000 Kilo = 1000 )
const (
GoldenRatio = 0.618
)
Variables ¶
var ( PosInf = math.Inf(1) NegInf = math.Inf(-1) )
Functions ¶
func BigIntToFloat64 ¶
func BiggerEqualThan ¶
func BiggerThan ¶
func CmpInt64Array ¶
func ContainsInt ¶
func DetectMaxPrec ¶
func DetectMaxPrec(vals []ElegantFloat, humanReadPrec int) int
func DetectMaxPrecRaw ¶
func ElegantFloatArrayToFloatArray ¶
func ElegantFloatArrayToFloatArray(in []ElegantFloat) []float64
func Float64ToByte ¶
Converts the float64 into an uint64 without changing the bits, it's the way the bits are interpreted that change. big endian references: https://stackoverflow.com/questions/37758267/golang-float64bits https://stackoverflow.com/questions/43693360/convert-float64-to-byte-array
func FloatAlmostEqual ¶
func FloatsEqual ¶
func FloatsPtrToFloats ¶
func FloatsToFloatsPtr ¶
func FormatFloat64 ¶
func FormatInt64 ¶
func FormatUint16 ¶
func FormatUint32 ¶
func FormatUint64 ¶
func FormatUint8 ¶
func IsEvenInt64 ¶
func IsEvenUint64 ¶
func IsOddInt64 ¶
func IsOddUint64 ¶
func JoinFormatInt ¶
func MaxFloat64 ¶
func MinFloat64 ¶
func MinUintArray ¶
func ParseFloat64 ¶
func RealGoldenRatio ¶
func RealGoldenRatio() float64
func RemoveDuplicate ¶
func ReverseBigFloats ¶
func ReverseBigInts ¶
func ReverseFloats ¶
func ReverseFloats(in []float64)
func ReverseInt64s ¶
func ReverseInt64s(in []int64)
func ReverseInts ¶
func ReverseInts(in []int)
func ReverseUints ¶
func ReverseUints(in []uint)
func SmallerEqualThan ¶
func SmallerThan ¶
func SortBigFloats ¶
func SortBigInts ¶
func SortFloats ¶
func SortFloats(in []float64)
func SortInt64s ¶
func SortInt64s(in []int64)
Types ¶
type ElegantFloat ¶
type ElegantFloat struct {
// contains filtered or unexported fields
}
original -> prec: 2 -> humanReadPrec: 2 37 -> 37.00 -> 37.00 12237.89374 -> 12237.89 -> 12237.89 3.3483300000000003 -> 3.35 -> 3.35 0.00883300000000003 -> 0.01 -> 0.0088 0.000012800003 -> 0.00 -> 0.000013
func NewElegantFloat ¶
func NewElegantFloat(val float64, prec int) ElegantFloat
func NewElegantFloatArray ¶
func NewElegantFloatArray(vals []float64, prec int) []ElegantFloat
func NewElegantFloatPtrArray ¶
func NewElegantFloatPtrArray(vals []*float64, prec int) []*ElegantFloat
func NewElegantFloatPtrArray2 ¶
func NewElegantFloatPtrArray2(vals []float64, prec int) []*ElegantFloat
func NewElegantFloatPtrArray3 ¶
func NewElegantFloatPtrArray3(vals []float64, prec int, nilVal float64) []*ElegantFloat
func (*ElegantFloat) JSON ¶
func (t *ElegantFloat) JSON(fmtNaNasNull bool) ([]byte, error)
What will happen if value is math.NaN? it will output bytes buffer `"NaN"`
func (ElegantFloat) MarshalJSON ¶
func (t ElegantFloat) MarshalJSON() ([]byte, error)
MarshalJSON will marshal using 2006-01-02T15:04:05+07:00 layout
FIXME if t.val = math.NaN and t.JSON(false), json.Marshal(t) will output error: json: error calling MarshalJSON for type *gnum.ElegantFloat: invalid character 'N' looking for beginning of value why and how to fix?
func (*ElegantFloat) Raw ¶
func (t *ElegantFloat) Raw() float64
func (*ElegantFloat) SetHumanReadPrec ¶
func (t *ElegantFloat) SetHumanReadPrec(humanReadPrec int)
func (*ElegantFloat) SetPrec ¶
func (t *ElegantFloat) SetPrec(prec int)
func (*ElegantFloat) String ¶
func (t *ElegantFloat) String() string
func (*ElegantFloat) UnmarshalJSON ¶
func (t *ElegantFloat) UnmarshalJSON(b []byte) error
TODO: NaN +-Inf会被ParseFloat64认为是错误吗,需要测试一下 UnmarshalJSON will unmarshal using 2006-01-02T15:04:05+07:00 layout