xnumber

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2020 License: MIT Imports: 3 Imported by: 7

README

xnumber

References
  • xtesting*
Functions
  • type Accuracy func() float64
  • NewAccuracy(eps float64) Accuracy
  • var DefaultAccuracy Accuracy
  • (eps Accuracy) Equal(a, b float64) bool
  • (eps Accuracy) NotEqual(a, b float64) bool
  • (eps Accuracy) Greater(a, b float64) bool
  • (eps Accuracy) Smaller(a, b float64) bool
  • (eps Accuracy) GreaterOrEqual(a, b float64) bool
  • (eps Accuracy) SmallerOrEqual(a, b float64) bool
  • RenderByte(b float64) string
  • Bool(b bool) int
  • ParseInt(s string, base int) (int, error)
  • ParseInt8(s string, base int) (int8, error)
  • ParseInt16(s string, base int) (int16, error)
  • ParseInt32(s string, base int) (int32, error)
  • ParseInt64(s string, base int) (int64, error)
  • ParseUint(s string, base int) (uint, error)
  • ParseUint8(s string, base int) (uint8, error)
  • ParseUint16(s string, base int) (uint16, error)
  • ParseUint32(s string, base int) (uint32, error)
  • ParseUint64(s string, base int) (uint64, error)
  • ParseFloat32(s string) (float32, error)
  • ParseFloat64(s string) (float64, error)
  • Atoi(s string) (int, error)
  • Atoi8(s string) (int8, error)
  • Atoi16(s string) (int16, error)
  • Atoi32(s string) (int32, error)
  • Atoi64(s string) (int64, error)
  • Atou(s string) (uint, error)
  • Atou8(s string) (uint8, error)
  • Atou16(s string) (uint16, error)
  • Atou32(s string) (uint32, error)
  • Atou64(s string) (uint64, error)
  • Atof32(s string) (float32, error)
  • Atof64(s string) (float64, error)
  • FormatInt(i int, base int) string
  • FormatInt8(i int8, base int) string
  • FormatInt16(i int16, base int) string
  • FormatInt32(i int32, base int) string
  • FormatInt64(i int64, base int) string
  • FormatUint(i uint, base int) string
  • FormatUint8(i uint8, base int) string
  • FormatUint16(i uint16, base int) string
  • FormatUint32(i uint32, base int) string
  • FormatUint64(i uint64, base int) string
  • FormatFloat32(f float32, fmt byte, prec int) string
  • FormatFloat64(f float64, fmt byte, prec int) string
  • Itoa(i int) string
  • I8toa(i int8) string
  • I16toa(i int16) string
  • I32toa(i int32) string
  • I64toa(i int64) string
  • Utoa(i uint) string
  • U8toa(i uint8) string
  • U16toa(i uint16) string
  • U32toa(i uint32) string
  • U64toa(i uint64) string
  • F32toa(f float32) string
  • F64toa(f float64) string
  • MinInt8
  • MinInt16
  • MinInt32
  • MinInt64
  • MinUint8
  • MinUint16
  • MinUint32
  • MinUint64
  • MaxInt8
  • MaxInt16
  • MaxInt32
  • MaxInt64
  • MaxUint8
  • MaxUint16
  • MaxUint32
  • MaxUint64
  • MaxFloat32
  • SmallestNonzeroFloat32
  • MaxFloat64
  • SmallestNonzeroFloat64

Documentation

Index

Constants

View Source
const (
	MinInt8   = int8(-128)                  // -1 << 7
	MinInt16  = int16(-32768)               // -1 << 15
	MinInt32  = int32(-2147483648)          // -1 << 31
	MinInt64  = int64(-9223372036854775808) // -1 << 63
	MinUint8  = uint8(0)                    // 0
	MinUint16 = uint16(0)                   // 0
	MinUint32 = uint32(0)                   // 0
	MinUint64 = uint64(0)                   // 0

	MaxInt8   = int8(127)                    // 1<<7 - 1
	MaxInt16  = int16(32767)                 //  1<<15 - 1
	MaxInt32  = int32(2147483647)            //  1<<31 - 1
	MaxInt64  = int64(9223372036854775807)   // 1<<63 - 1
	MaxUint8  = uint8(255)                   //  1<<8 - 1
	MaxUint16 = uint16(65535)                // 1<<16 - 1
	MaxUint32 = uint32(4294967295)           // 1<<32 - 1
	MaxUint64 = uint64(18446744073709551615) // 1<<64 - 1

	MaxFloat32             = float32(math.MaxFloat32)             // 2**127 * (2**24 - 1) / 2**23
	SmallestNonzeroFloat32 = float32(math.SmallestNonzeroFloat32) // 1 / 2**(127 - 1 + 23)
	MaxFloat64             = float64(math.MaxFloat64)             // 2**1023 * (2**53 - 1) / 2**52
	SmallestNonzeroFloat64 = float64(math.SmallestNonzeroFloat64) // 1 / 2**(1023 - 1 + 52)
)

Variables

View Source
var DefaultAccuracy = NewAccuracy(1e-3)

DefaultAccuracy means default accuracy, use 1e-3.

Functions

func Atof32

func Atof32(s string) (float32, error)

func Atof64

func Atof64(s string) (float64, error)

func Atoi

func Atoi(s string) (int, error)

func Atoi16

func Atoi16(s string) (int16, error)

func Atoi32

func Atoi32(s string) (int32, error)

func Atoi64

func Atoi64(s string) (int64, error)

func Atoi8

func Atoi8(s string) (int8, error)

func Atou

func Atou(s string) (uint, error)

func Atou16

func Atou16(s string) (uint16, error)

func Atou32

func Atou32(s string) (uint32, error)

func Atou64

func Atou64(s string) (uint64, error)

func Atou8

func Atou8(s string) (uint8, error)

func Bool added in v1.3.3

func Bool(b bool) int

Bool returns 1 if value is true, otherwise returns 0.

func F32toa

func F32toa(f float32) string

func F64toa

func F64toa(f float64) string

func FormatFloat32

func FormatFloat32(f float32, fmt byte, prec int) string

func FormatFloat64

func FormatFloat64(f float64, fmt byte, prec int) string

func FormatInt

func FormatInt(i int, base int) string

func FormatInt16

func FormatInt16(i int16, base int) string

func FormatInt32

func FormatInt32(i int32, base int) string

func FormatInt64

func FormatInt64(i int64, base int) string

func FormatInt8

func FormatInt8(i int8, base int) string

func FormatUint

func FormatUint(i uint, base int) string

func FormatUint16

func FormatUint16(i uint16, base int) string

func FormatUint32

func FormatUint32(i uint32, base int) string

func FormatUint64

func FormatUint64(i uint64, base int) string

func FormatUint8

func FormatUint8(i uint8, base int) string

func I16toa

func I16toa(i int16) string

func I32toa

func I32toa(i int32) string

func I64toa

func I64toa(i int64) string

func I8toa

func I8toa(i int8) string

func Itoa

func Itoa(i int) string

func ParseFloat32

func ParseFloat32(s string) (float32, error)

func ParseFloat64

func ParseFloat64(s string) (float64, error)

func ParseInt

func ParseInt(s string, base int) (int, error)

func ParseInt16

func ParseInt16(s string, base int) (int16, error)

func ParseInt32

func ParseInt32(s string, base int) (int32, error)

func ParseInt64

func ParseInt64(s string, base int) (int64, error)

func ParseInt8

func ParseInt8(s string, base int) (int8, error)

func ParseUint

func ParseUint(s string, base int) (uint, error)

func ParseUint16

func ParseUint16(s string, base int) (uint16, error)

func ParseUint32

func ParseUint32(s string, base int) (uint32, error)

func ParseUint64

func ParseUint64(s string, base int) (uint64, error)

func ParseUint8

func ParseUint8(s string, base int) (uint8, error)

func RenderByte

func RenderByte(b float64) string

RenderByte renders a byte size to string (using %.2f), support `B` `KB` `MB` `GB` `TB`.

func U16toa

func U16toa(i uint16) string

func U32toa

func U32toa(i uint32) string

func U64toa

func U64toa(i uint64) string

func U8toa

func U8toa(i uint8) string

func Utoa

func Utoa(i uint) string

Types

type Accuracy

type Accuracy func() float64

Accuracy includes some accuracy functions using the given accuracy.

func NewAccuracy

func NewAccuracy(eps float64) Accuracy

NewAccuracy creates an Accuracy, using eps as accuracy.

func (Accuracy) Equal

func (eps Accuracy) Equal(a, b float64) bool

Equal checks eq between two float64.

func (Accuracy) Greater

func (eps Accuracy) Greater(a, b float64) bool

Greater checks gt between two float64.

func (Accuracy) GreaterOrEqual

func (eps Accuracy) GreaterOrEqual(a, b float64) bool

GreaterOrEqual checks gte between two float64.

func (Accuracy) NotEqual added in v1.3.4

func (eps Accuracy) NotEqual(a, b float64) bool

NotEqual checks neq between two float64.

func (Accuracy) Smaller

func (eps Accuracy) Smaller(a, b float64) bool

Smaller checks lt between two float64.

func (Accuracy) SmallerOrEqual

func (eps Accuracy) SmallerOrEqual(a, b float64) bool

SmallerOrEqual checks lte between two float64.

Jump to

Keyboard shortcuts

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