github.com/Aoi-hosizora/ahlib@v1.5.1-0.20230404072829-241b93cf91c7/xnumber/README.md (about) 1 # xnumber 2 3 ## Dependencies 4 5 + (xtesting) 6 7 ## Documents 8 9 ### Types 10 11 + `type Accuracy func` 12 13 ### Variables 14 15 + None 16 17 ### Constants 18 19 + `const MinInt8 int8` 20 + `const MinInt16 int16` 21 + `const MinInt32 int32` 22 + `const MinInt64 int64` 23 + `const MinUint8 uint8` 24 + `const MinUint16 uint16` 25 + `const MinUint32 uint32` 26 + `const MinUint64 uint64` 27 + `const MaxInt8 int8` 28 + `const MaxInt16 int16` 29 + `const MaxInt32 int32` 30 + `const MaxInt64 int64` 31 + `const MaxUint8 uint8` 32 + `const MaxUint16 uint16` 33 + `const MaxUint32 uint32` 34 + `const MaxUint64 uint64` 35 + `const MaxFloat32 float32` 36 + `const SmallestNonzeroFloat32 float32` 37 + `const MaxFloat64 float64` 38 + `const SmallestNonzeroFloat64 float64` 39 40 ### Functions 41 42 #### Common functions 43 44 + `func NewAccuracy(eps float64) Accuracy` 45 + `func EqualInAccuracy(a, b float64) bool` 46 + `func NotEqualInAccuracy(a, b float64) bool` 47 + `func GreaterInAccuracy(a, b float64) bool` 48 + `func LessInAccuracy(a, b float64) bool` 49 + `func GreaterOrEqualInAccuracy(a, b float64) bool` 50 + `func LessOrEqualInAccuracy(a, b float64) bool` 51 + `func FormatByteSize(bytes float64) string` 52 + `func Bool(b bool) int` 53 + `func IntBitLength() int` 54 + `func FastrandUint32() uint32` 55 + `func FastrandUint64() uint64` 56 + `func FastrandInt32() int32` 57 + `func FastrandInt64() int64` 58 + `func IsPowerOfTwo(x int) bool` 59 60 #### Overflow checker functions 61 62 + `func OverflowWhenAddInt8(augend, addend int8) bool` 63 + `func OverflowWhenAddInt16(augend, addend int16) bool` 64 + `func OverflowWhenAddInt32(augend, addend int32) bool` 65 + `func OverflowWhenAddInt64(augend, addend int64) bool` 66 + `func OverflowWhenAddInt(augend, addend int) bool` 67 + `func OverflowWhenSubtractInt8(minuend, subtrahend int8) bool` 68 + `func OverflowWhenSubtractInt16(minuend, subtrahend int16) bool` 69 + `func OverflowWhenSubtractInt32(minuend, subtrahend int32) bool` 70 + `func OverflowWhenSubtractInt64(minuend, subtrahend int64) bool` 71 + `func OverflowWhenSubtractInt(minuend, subtrahend int) bool` 72 + `func OverflowWhenAddUint8(augend, addend uint8) bool` 73 + `func OverflowWhenAddUint16(augend, addend uint16) bool` 74 + `func OverflowWhenAddUint32(augend, addend uint32) bool` 75 + `func OverflowWhenAddUint64(augend, addend uint64) bool` 76 + `func OverflowWhenAddUint(augend, addend uint) bool` 77 + `func OverflowWhenSubtractUint8(minuend, subtrahend uint8) bool` 78 + `func OverflowWhenSubtractUint16(minuend, subtrahend uint16) bool` 79 + `func OverflowWhenSubtractUint32(minuend, subtrahend uint32) bool` 80 + `func OverflowWhenSubtractUint64(minuend, subtrahend uint64) bool` 81 + `func OverflowWhenSubtractUint(minuend, subtrahend uint) bool` 82 83 #### Parse and format functions 84 85 + `func ParseInt(s string, base int) (int, error)` 86 + `func ParseInt8(s string, base int) (int8, error)` 87 + `func ParseInt16(s string, base int) (int16, error)` 88 + `func ParseInt32(s string, base int) (int32, error)` 89 + `func ParseInt64(s string, base int) (int64, error)` 90 + `func ParseUint(s string, base int) (uint, error)` 91 + `func ParseUint8(s string, base int) (uint8, error)` 92 + `func ParseUint16(s string, base int) (uint16, error)` 93 + `func ParseUint32(s string, base int) (uint32, error)` 94 + `func ParseUint64(s string, base int) (uint64, error)` 95 + `func ParseFloat32(s string) (float32, error)` 96 + `func ParseFloat64(s string) (float64, error)` 97 + `func ParseIntOr(s string, base int, o int) int` 98 + `func ParseInt8Or(s string, base int, o int8) int8` 99 + `func ParseInt16Or(s string, base int, o int16) int16` 100 + `func ParseInt32Or(s string, base int, o int32) int32` 101 + `func ParseInt64Or(s string, base int, o int64) int64` 102 + `func ParseUintOr(s string, base int, o uint) uint` 103 + `func ParseUint8Or(s string, base int, o uint8) uint8` 104 + `func ParseUint16Or(s string, base int, o uint16) uint16` 105 + `func ParseUint32Or(s string, base int, o uint32) uint32` 106 + `func ParseUint64Or(s string, base int, o uint64) uint64` 107 + `func ParseFloat32Or(s string, o float32) float32` 108 + `func ParseFloat64Or(s string, o float64) float64` 109 + `func Atoi(s string) (int, error)` 110 + `func Atoi8(s string) (int8, error)` 111 + `func Atoi16(s string) (int16, error)` 112 + `func Atoi32(s string) (int32, error)` 113 + `func Atoi64(s string) (int64, error)` 114 + `func Atou(s string) (uint, error)` 115 + `func Atou8(s string) (uint8, error)` 116 + `func Atou16(s string) (uint16, error)` 117 + `func Atou32(s string) (uint32, error)` 118 + `func Atou64(s string) (uint64, error)` 119 + `func Atof32(s string) (float32, error)` 120 + `func Atof64(s string) (float64, error)` 121 + `func AtoiOr(s string, o int) int` 122 + `func Atoi8Or(s string, o int8) int8` 123 + `func Atoi16Or(s string, o int16) int16` 124 + `func Atoi32Or(s string, o int32) int32` 125 + `func Atoi64Or(s string, o int64) int64` 126 + `func AtouOr(s string, o uint) uint` 127 + `func Atou8Or(s string, o uint8) uint8` 128 + `func Atou16Or(s string, o uint16) uint16` 129 + `func Atou32Or(s string, o uint32) uint32` 130 + `func Atou64Or(s string, o uint64) uint64` 131 + `func Atof32Or(s string, o float32) float32` 132 + `func Atof64Or(s string, o float64) float64` 133 + `func FormatInt(i int, base int) string` 134 + `func FormatInt8(i int8, base int) string` 135 + `func FormatInt16(i int16, base int) string` 136 + `func FormatInt32(i int32, base int) string` 137 + `func FormatInt64(i int64, base int) string` 138 + `func FormatUint(u uint, base int) string` 139 + `func FormatUint8(u uint8, base int) string` 140 + `func FormatUint16(u uint16, base int) string` 141 + `func FormatUint32(u uint32, base int) string` 142 + `func FormatUint64(u uint64, base int) string` 143 + `func FormatFloat32(f float32, fmt byte, prec int) string` 144 + `func FormatFloat64(f float64, fmt byte, prec int) string` 145 + `func Itoa(i int) string` 146 + `func I8toa(i int8) string` 147 + `func I16toa(i int16) string` 148 + `func I32toa(i int32) string` 149 + `func I64toa(i int64) string` 150 + `func Utoa(u uint) string` 151 + `func U8toa(u uint8) string` 152 + `func U16toa(u uint16) string` 153 + `func U32toa(u uint32) string` 154 + `func U64toa(u uint64) string` 155 + `func F32toa(f float32) string` 156 + `func F64toa(f float64) string` 157 158 #### Range functions 159 160 + `func IntRange(from, to, step int) []int` 161 + `func Int8Range(from, to, step int8) []int8` 162 + `func Int16Range(from, to, step int16) []int16` 163 + `func Int32Range(from, to, step int32) []int32` 164 + `func Int64Range(from, to, step int64) []int64` 165 + `func UintRange(from, to, step uint, reverseFlag ...bool) []uint` 166 + `func Uint8Range(from, to, step uint8, reverseFlag ...bool) []uint8` 167 + `func Uint16Range(from, to, step uint16, reverseFlag ...bool) []uint16` 168 + `func Uint32Range(from, to, step uint32, reverseFlag ...bool) []uint32` 169 + `func Uint64Range(from, to, step uint64, reverseFlag ...bool) []uint64` 170 + `func ReverseIntSlice(s []int)` 171 + `func ReverseInt8Slice(s []int8)` 172 + `func ReverseInt16Slice(s []int16)` 173 + `func ReverseInt32Slice(s []int32)` 174 + `func ReverseInt64Slice(s []int64)` 175 + `func ReverseUintSlice(s []uint)` 176 + `func ReverseUint8Slice(s []uint8)` 177 + `func ReverseUint16Slice(s []uint16)` 178 + `func ReverseUint32Slice(s []uint32)` 179 + `func ReverseUint64Slice(s []uint64)` 180 181 ### Methods 182 183 + `func (eps Accuracy) Equal(a, b float64) bool` 184 + `func (eps Accuracy) NotEqual(a, b float64) bool` 185 + `func (eps Accuracy) Greater(a, b float64) bool` 186 + `func (eps Accuracy) Less(a, b float64) bool` 187 + `func (eps Accuracy) GreaterOrEqual(a, b float64) bool` 188 + `func (eps Accuracy) LessOrEqual(a, b float64) bool`