Documentation ¶
Index ¶
- Constants
- func Abs[T gust.Digit](d T) T
- func AppendInt(dst []byte, i int64, base int) []byte
- func AppendUint(dst []byte, i uint64, base int) []byte
- func As[T gust.Digit, D gust.Digit](v T) gust.Result[D]
- func Atoi(s string) (int, error)
- func CheckedAdd[T gust.Integer](a, b T) gust.Option[T]
- func CheckedMul[T gust.Integer](a, b T) gust.Option[T]
- func FormatByDict(dict []byte, num uint64) string
- func FormatInt(i int64, base int) string
- func FormatUint(i uint64, base int) string
- func FromBool[T ~bool, D gust.Digit](v T) D
- func FromBools[T ~bool, D gust.Digit](a []T) (b []D)
- func Itoa(i int) string
- func Max[T gust.Integer]() T
- func ParseByDict[D gust.Digit](dict []byte, numStr string) gust.Result[D]
- func ParseInt(s string, base int, bitSize int) gust.Result[int64]
- func ParseUint(s string, base int, bitSize int) gust.Result[uint64]
- func SaturatingAdd[T gust.Integer](a, b T) T
- func SaturatingSub[T gust.Digit](a, b T) T
- func SliceAs[T gust.Digit, D gust.Digit](a []T) (b []D, err error)
- func ToBool[T gust.Digit](v T) bool
- func ToBools[T gust.Digit](a []T) []bool
- func TryFromString[T ~string, D gust.Digit](v T, base int, bitSize int) gust.Result[D]
- func TryFromStrings[T ~string, D gust.Digit](a []T, base int, bitSize int) gust.Result[[]D]
Constants ¶
const ( Host64bit = strconv.IntSize == 64 Host32bit = ^uint(0)>>32 == 0 )
Variables ¶
This section is empty.
Functions ¶
func AppendInt ¶ added in v1.1.0
AppendInt appends the string form of the integer i, as generated by FormatInt, to dst and returns the extended buffer. NOTE:
Compatible with standard package strconv.
func AppendUint ¶ added in v1.1.0
AppendUint appends the string form of the unsigned integer i, as generated by FormatUint, to dst and returns the extended buffer. NOTE:
Compatible with standard package strconv.
func FormatByDict ¶ added in v1.1.0
FormatByDict convert num into corresponding string according to dict.
func FormatInt ¶ added in v1.1.0
FormatInt returns the string representation of i in the given base, for 2 <= base <= 62. NOTE:
Compatible with standard package strconv.
func FormatUint ¶ added in v1.1.0
FormatUint returns the string representation of i in the given base, for 2 <= base <= 62. NOTE:
Compatible with standard package strconv.
func Itoa ¶ added in v1.1.0
Itoa is equivalent to FormatInt(int64(i), 10). NOTE:
Compatible with standard package strconv.
func ParseByDict ¶ added in v1.1.0
ParseByDict convert numStr into corresponding digit according to dict.
func ParseInt ¶ added in v1.1.0
ParseInt interprets a string s in the given base (0, 2 to 62) and bit size (0 to 64) and returns the corresponding value i.
If base == 0, the base is implied by the string's prefix: base 2 for "0b", base 8 for "0" or "0o", base 16 for "0x", and base 10 otherwise. Also, for base == 0 only, underscore characters are permitted per the Go integer literal syntax. If base is below 0, is 1, or is above 62, an error is returned.
The bitSize argument specifies the integer type that the result must fit into. Bit sizes 0, 8, 16, 32, and 64 correspond to int, int8, int16, int32, and int64. If bitSize is below 0 or above 64, an error is returned.
The errors that ParseInt returns have concrete type *NumError and include err.Num = s. If s is empty or contains invalid digits, err.Err = ErrSyntax and the returned value is 0; if the value corresponding to s cannot be represented by a signed integer of the given size, err.Err = ErrRange and the returned value is the maximum magnitude integer of the appropriate bitSize and sign. NOTE:
Compatible with standard package strconv.
func ParseUint ¶ added in v1.1.0
ParseUint is like ParseInt but for unsigned numbers. NOTE:
Compatible with standard package strconv.
func SaturatingAdd ¶ added in v1.0.0
func SaturatingSub ¶ added in v1.0.0
func TryFromString ¶ added in v1.1.0
TryFromString converts ~string to digit. If base == 0, the base is implied by the string's prefix: base 2 for "0b", base 8 for "0" or "0o", base 16 for "0x", and base 10 otherwise. Also, for base == 0 only, underscore characters are permitted per the Go integer literal syntax. If base is below 0, is 1, or is above 62, an error is returned.
Types ¶
This section is empty.