Overview
strconv
provides functions for converting strings to numbers and numbers to strings.
Aliases
This section is empty.
Constants
double_minus_infinity = u64(0xFFF0000000000000)
f64 constants
Sum types
This section is empty.
Functions
atof64 return a f64 from a string doing a parsing operation
atof64 parses the string s
, and if possible, converts it into a f64 number
atof_quick return a f64 number from a string in a quick way
atoi is equivalent to parse_int(s, 10, 0), converted to type int.
fn common_parse_int(_s string, base int, _bit_size int, error_on_non_digit bool, error_on_high_digit bool) !i64
common_parse_int is called by parse int and allows the parsing to stop on non or invalid digit characters and return with an error
fn common_parse_uint(s string, _base int, _bit_size int, error_on_non_digit bool, error_on_high_digit bool) !u64
common_parse_uint is called by parse_uint and allows the parsing to stop on non or invalid digit characters and return with an error
the first returned value contains the parsed value, the second returned value contains the error code (0 = OK, >1 = index of first non-parseable character + 1, -1 = wrong base, -2 = wrong bit size, -3 = overflow)
dec_digits return the number of decimal digit of an u64
f32_to_str returns a string
in scientific notation with max n_digit
after the dot.
TODO: Investigate precision issues f32_to_str_l returns f
as a string
in decimal notation with a maximum of 6 digits after the dot.
Example:
assert strconv.f32_to_str_l(34.1234567) == '34.12346'
f32_to_str_l_with_dot returns f
as a string
in decimal notation with a maximum of 6 digits after the dot.
If the decimal digits after the dot are zero, a '.0' is appended for clarity.
Example:
assert strconv.f32_to_str_l_with_dot(34.) == '34.0'
f32_to_str_pad returns a string
in scientific notation with max n_digit
after the dot.
f64_to_str returns f
as a string
in scientific notation with max n_digit
digits after the dot.
f64_to_str_l returns f
as a string
in decimal notation with a maximum of 18 digits after the dot.
Example:
assert strconv.f64_to_str_l(123.1234567891011121) == '123.12345678910111'
f64_to_str_l_with_dot returns f
as a string
in decimal notation with a maximum of 18 digits after the dot.
If the decimal digits after the dot are zero, a '.0' is appended for clarity.
Example:
assert strconv.f64_to_str_l_with_dot (34.) == '34.0'
f64_to_str_lnd1 formats a f64 to a string
with dec_digit
digits after the dot.
f64_to_str returns f
as a string
in scientific notation with max n_digit
digits after the dot.
max int64 9223372036854775807
format_dec_sb format a u64
format_dec_sb formats an u64 using a strings.Builder
.
strings.Builder version of format_fl
format_int returns the string representation of the number n in base radix
for digit values > 10, this function uses the small latin leters a-z.
format_str returns a string
formatted according to the options set in p
.
format_str_sb is a strings.Builder
version of format_str
.
format_uint returns the string representation of the number n in base radix
for digit values > 10, this function uses the small latin leters a-z.
ftoa_64 returns a string in scientific notation with max 17 digits after the dot.
Example:
assert strconv.ftoa_64(123.1234567891011121) == '1.2312345678910111e+02'
ftoa_long_32 returns f
as a string
in decimal notation with a maximum of 6 digits after the dot.
Example:
assert strconv.ftoa_long_32(34.1234567) == '34.12346'
ftoa_long_64 returns f
as a string
in decimal notation with a maximum of 17 digits after the dot.
Example:
assert strconv.f64_to_str_l(123.1234567891011121) == '123.12345678910111'
fxx_to_str_l_parse returns a string
in decimal notation converted from a floating-point string
in scientific notation.
Example:
assert strconv.fxx_to_str_l_parse('34.22e+00') == '34.22'
fxx_to_str_l_parse_with_dot returns a string
in decimal notation converted from a floating-point string
in scientific notation.
If the decimal digits after the dot are zero, a '.0' is appended for clarity.
Example:
assert strconv.fxx_to_str_l_parse_with_dot ('34.e+01') == '340.0'
parse_int interprets a string s in the given base (0, 2 to 36) and bit size (0 to 64) and returns the corresponding value i.
If the base argument is 0, the true base is implied by the string's prefix: 2 for "0b", 8 for "0" or "0o", 16 for "0x", and 10 otherwise.
Also, for argument base 0 only, underscore characters are permitted as defined by the Go syntax for integer literals.
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.
parse_uint is like parse_int but for unsigned numbers.
remove_tail_zeros strips traling zeros from s
and return the resulting string
.
Structs
pub struct BF_param {
pub mut:
pad_ch u8 = u8(` `) // padding char
len0 int = -1 // default len for whole the number or string
len1 int = 6 // number of decimal digits, if needed
positive bool = true // mandatory: the sign of the number passed
sign_flag bool // flag for print sign as prefix in padding
allign Align_text = .right // alignment of the string
rm_tail_zero bool // remove the tail zeros from floats
}
Interfaces
This section is empty.
f32 constants