Expand description
Public API for the number format packed struct.
This has a consistent API whether or not the format
feature is
enabled, however, most functionality will be disabled if the feature
is not enabled.
§Pre-Defined Formats
These are the pre-defined formats for parsing numbers from various programming, markup, and data languages.
- STANDARD
RUST_LITERAL
RUST_STRING
PYTHON_LITERAL
PYTHON_STRING
PYTHON3_LITERAL
PYTHON3_STRING
PYTHON36_LITERAL
PYTHON35_LITERAL
PYTHON2_LITERAL
PYTHON2_STRING
CXX_LITERAL
CXX_STRING
CXX_HEX_LITERAL
CXX_HEX_STRING
CXX20_LITERAL
CXX20_STRING
CXX20_HEX_LITERAL
CXX20_HEX_STRING
CXX17_LITERAL
CXX17_STRING
CXX17_HEX_LITERAL
CXX17_HEX_STRING
CXX14_LITERAL
CXX14_STRING
CXX14_HEX_STRING
CXX11_LITERAL
CXX11_STRING
CXX11_HEX_STRING
CXX03_LITERAL
CXX03_STRING
CXX98_LITERAL
CXX98_STRING
C_LITERAL
C_STRING
C_HEX_LITERAL
C_HEX_STRING
C18_LITERAL
C18_STRING
C18_HEX_LITERAL
C18_HEX_STRING
C11_LITERAL
C11_STRING
C11_HEX_LITERAL
C11_HEX_STRING
C99_LITERAL
C99_STRING
C99_HEX_LITERAL
C99_HEX_STRING
C90_LITERAL
C90_STRING
C90_HEX_STRING
C89_LITERAL
C89_STRING
C89_HEX_STRING
RUBY_LITERAL
RUBY_OCTAL_LITERAL
RUBY_STRING
SWIFT_LITERAL
SWIFT_STRING
GO_LITERAL
GO_STRING
HASKELL_LITERAL
HASKELL_STRING
JAVASCRIPT_LITERAL
JAVASCRIPT_STRING
PERL_LITERAL
PERL_STRING
PHP_LITERAL
PHP_STRING
JAVA_LITERAL
JAVA_STRING
R_LITERAL
R_STRING
KOTLIN_LITERAL
KOTLIN_STRING
JULIA_LITERAL
JULIA_STRING
JULIA_HEX_LITERAL
JULIA_HEX_STRING
CSHARP_LITERAL
CSHARP_STRING
CSHARP7_LITERAL
CSHARP7_STRING
CSHARP6_LITERAL
CSHARP6_STRING
CSHARP5_LITERAL
CSHARP5_STRING
CSHARP4_LITERAL
CSHARP4_STRING
CSHARP3_LITERAL
CSHARP3_STRING
CSHARP2_LITERAL
CSHARP2_STRING
CSHARP1_LITERAL
CSHARP1_STRING
KAWA_LITERAL
KAWA_STRING
GAMBITC_LITERAL
GAMBITC_STRING
GUILE_LITERAL
GUILE_STRING
CLOJURE_LITERAL
CLOJURE_STRING
ERLANG_LITERAL
ERLANG_STRING
ELM_LITERAL
ELM_STRING
SCALA_LITERAL
SCALA_STRING
ELIXIR_LITERAL
ELIXIR_STRING
FORTRAN_LITERAL
FORTRAN_STRING
D_LITERAL
D_STRING
COFFEESCRIPT_LITERAL
COFFEESCRIPT_STRING
COBOL_LITERAL
COBOL_STRING
FSHARP_LITERAL
FSHARP_STRING
VB_LITERAL
VB_STRING
OCAML_LITERAL
OCAML_STRING
OBJECTIVEC_LITERAL
OBJECTIVEC_STRING
REASONML_LITERAL
REASONML_STRING
OCTAVE_LITERAL
OCTAVE_STRING
MATLAB_LITERAL
MATLAB_STRING
ZIG_LITERAL
ZIG_STRING
SAGE_LITERAL
SAGE_STRING
JSON
TOML
YAML
XML
SQLITE
POSTGRESQL
MYSQL
MONGODB
§Syntax Flags
Bitflags to get and set syntax flags for the format packed struct.
REQUIRED_INTEGER_DIGITS
REQUIRED_FRACTION_DIGITS
REQUIRED_EXPONENT_DIGITS
REQUIRED_MANTISSA_DIGITS
REQUIRED_DIGITS
NO_POSITIVE_MANTISSA_SIGN
REQUIRED_MANTISSA_SIGN
NO_EXPONENT_NOTATION
NO_POSITIVE_EXPONENT_SIGN
REQUIRED_EXPONENT_SIGN
NO_EXPONENT_WITHOUT_FRACTION
NO_SPECIAL
CASE_SENSITIVE_SPECIAL
NO_INTEGER_LEADING_ZEROS
NO_FLOAT_LEADING_ZEROS
REQUIRED_EXPONENT_NOTATION
CASE_SENSITIVE_EXPONENT
CASE_SENSITIVE_BASE_PREFIX
CASE_SENSITIVE_BASE_SUFFIX
§Digit Separator Flags
Bitflags to get and set digit separators flags for the format packed struct.
INTEGER_INTERNAL_DIGIT_SEPARATOR
FRACTION_INTERNAL_DIGIT_SEPARATOR
EXPONENT_INTERNAL_DIGIT_SEPARATOR
INTEGER_LEADING_DIGIT_SEPARATOR
FRACTION_LEADING_DIGIT_SEPARATOR
EXPONENT_LEADING_DIGIT_SEPARATOR
INTEGER_TRAILING_DIGIT_SEPARATOR
FRACTION_TRAILING_DIGIT_SEPARATOR
EXPONENT_TRAILING_DIGIT_SEPARATOR
INTEGER_CONSECUTIVE_DIGIT_SEPARATOR
FRACTION_CONSECUTIVE_DIGIT_SEPARATOR
EXPONENT_CONSECUTIVE_DIGIT_SEPARATOR
INTERNAL_DIGIT_SEPARATOR
LEADING_DIGIT_SEPARATOR
TRAILING_DIGIT_SEPARATOR
CONSECUTIVE_DIGIT_SEPARATOR
SPECIAL_DIGIT_SEPARATOR
§Character Shifts and Masks
Bitmasks and bitshifts to get and set control characters for the format packed struct.
DIGIT_SEPARATOR_SHIFT
DIGIT_SEPARATOR
BASE_PREFIX_SHIFT
BASE_PREFIX
BASE_SUFFIX_SHIFT
BASE_SUFFIX
MANTISSA_RADIX_SHIFT
MANTISSA_RADIX
RADIX_SHIFT
RADIX
EXPONENT_BASE_SHIFT
EXPONENT_BASE
EXPONENT_RADIX_SHIFT
EXPONENT_RADIX
§Character Functions
Functions to get control characters from the format packed struct.
digit_separator
base_prefix
base_suffix
mantissa_radix
exponent_base
exponent_radix
radix_from_flags
§Validators
Functions to validate control characters for the format packed struct.
Structs§
- Build number format from specifications.
Constants§
- Mask to extract the base prefix character.
- Shift to convert to and from a base prefix as a
u8
. - Mask to extract the base suffix character.
- Shift to convert to and from a base suffix as a
u8
. - Number format for a
C11
literal hexadecimal floating-point number. - Number format for a
C11
string hexadecimal floating-point number. - Number format for a
C11
literal floating-point number. - Number format for a
C11
string floating-point number. - Number format for a
C18
literal hexadecimal floating-point number. - Number format for a
C18
string hexadecimal floating-point number. - Number format for a
C18
literal floating-point number. - Number format for a
C18
string floating-point number. - Number format for a
C89
string hexadecimal floating-point number. - Number format for a
C89
literal floating-point number. - Number format for a
C89
string floating-point number. - Number format for a
C90
string hexadecimal floating-point number. - Number format for a
C90
literal floating-point number. - Number format for a
C90
string floating-point number. - Number format for a
C99
literal hexadecimal floating-point number. - Number format for a
C99
string hexadecimal floating-point number. - Number format for a
C99
literal floating-point number. - Number format for a
C99
string floating-point number. - Base prefixes are case-sensitive.
- Base suffixes are case-sensitive.
- Exponent characters are case-sensitive.
- Special (non-finite) values are case-sensitive.
- Number format for a
Clojure
literal floating-point number. - Number format to parse a
Clojure
float from string. - Number format for a
Cobol
literal floating-point number. - Number format to parse a
Cobol
float from string. - Number format for a
Coffeescript
literal floating-point number. - Number format to parse a
Coffeescript
float from string. - Multiple consecutive digit separators are allowed.
- Number format for a
C#1
literal floating-point number. - Number format to parse a
C#1
float from string. - Number format for a
C#2
literal floating-point number. - Number format to parse a
C#2
float from string. - Number format for a
C#3
literal floating-point number. - Number format to parse a
C#3
float from string. - Number format for a
C#4
literal floating-point number. - Number format to parse a
C#4
float from string. - Number format for a
C#5
literal floating-point number. - Number format to parse a
C#5
float from string. - Number format for a
C#6
literal floating-point number. - Number format to parse a
C#6
float from string. - Number format for a
C#7
literal floating-point number. - Number format to parse a
C#7
float from string. - Number format for a
C#
literal floating-point number. - Number format to parse a
C#
float from string. - Number format for a
C++03
literal floating-point number. - Number format for a
C++03
string floating-point number. - Number format for a
C++11
string hexadecimal floating-point number. - Number format for a
C++11
literal floating-point number. - Number format for a
C++11
string floating-point number. - Number format for a
C++14
string hexadecimal floating-point number. - Number format for a
C++14
literal floating-point number. - Number format for a
C++14
string floating-point number. - Number format for a
C++17
literal hexadecimal floating-point number. - Number format for a
C++17
string hexadecimal floating-point number. - Number format for a
C++17
literal floating-point number. - Number format for a
C++17
string floating-point number. - Number format for a
C++20
literal hexadecimal floating-point number. - Number format for a
C++20
string hexadecimal floating-point number. - Number format for a
C++20
literal floating-point number. - Number format for a
C++20
string floating-point number. - Number format for a
C++98
literal floating-point number. - Number format for a
C++98
string floating-point number. - Number format for a
C++
literal hexadecimal floating-point number. - Number format to parse a
C++
hexadecimal float from string. - Number format for a
C++
literal floating-point number. - Number format to parse a
C++
float from string. - Number format for a
C
literal hexadecimal floating-point number. - Number format to parse a
C
hexadecimal float from string. - Number format for a C literal floating-point number.
- Number format to parse a
C
float from string. - Mask to extract the digit separator character.
- Shift to convert to and from a digit separator as a
u8
. - Number format for a
D
literal floating-point number. - Number format to parse a
D
float from string. - Number format for an
Elixir
literal floating-point number. - Number format to parse an
Elixir
float from string. - Number format for an
Elm
literal floating-point number. - Number format to parse an
Elm
float from string. - Number format for an
Erlang
literal floating-point number. - Number format to parse an
Erlang
float from string. - Mask to extract the exponent base: the base the exponent is raised to.
- Shift to convert to and from an exponent base as a
u32
. - Multiple consecutive exponent digit separators are allowed.
- Digit separators are allowed between exponent digits.
- A digit separator is allowed before any exponent digits.
- Mask to extract the exponent radix: the radix for the exponent digits.
- Shift to convert to and from an exponent radix as a
u32
. - A digit separator is allowed after any exponent digits.
- Number format for a
FORTRAN
literal floating-point number. - Number format to parse a
FORTRAN
float from string. - Multiple consecutive fraction digit separators are allowed.
- Digit separators are allowed between fraction digits.
- A digit separator is allowed before any fraction digits.
- A digit separator is allowed after any fraction digits.
- Number format for a
F#
literal floating-point number. - Number format to parse a
F#
float from string. - Number format for a
Gambit-C
literal floating-point number. - Number format to parse a
Gambit-C
float from string. - Number format for a
Golang
literal floating-point number. - Number format to parse a
Golang
float from string. - Number format for a
Guile
literal floating-point number. - Number format to parse a
Guile
float from string. - Number format for a
Haskell
literal floating-point number. - Number format to parse a
Haskell
float from string. - Multiple consecutive integer digit separators are allowed.
- Digit separators are allowed between integer digits.
- A digit separator is allowed before any integer digits.
- A digit separator is allowed after any integer digits.
- Digit separators are allowed between digits.
- Number format for a
Javascript
literal floating-point number. - Number format to parse a
Javascript
float from string. - Number format for a
Java
literal floating-point number. - Number format to parse a
Java
float from string. - Number format for a
JSON
literal floating-point number. - Number format for a
Julia
literal floating-point number. - Number format to parse a
Julia
float from string. - Number format for a
Julia
literal floating-point number. - Number format to parse a
Julia
float from string. - Number format for a
Kawa
literal floating-point number. - Number format to parse a
Kawa
float from string. - Number format for a
Kotlin
literal floating-point number. - Number format to parse a
Kotlin
float from string. - A digit separator is allowed before any digits.
- Mask to extract the mantissa radix: the radix for the significant digits.
- Shift to convert to and from a mantissa radix as a
u32
. - Number format for an
Matlab
literal floating-point number. - Number format to parse an
Matlab
float from string. - Number format for a
MongoDB
literal floating-point number. - Number format for a
MySQL
literal floating-point number. - Exponent notation is not allowed.
- Exponent without a fraction component is not allowed.
- Leading zeros before a float value are not allowed.
- Leading zeros before an integer value are not allowed.
- Positive sign before the exponent is not allowed.
- Positive sign before the mantissa is not allowed.
- Special (non-finite) values are not allowed.
- Number format for an
Objective-C
literal floating-point number. - Number format to parse an
Objective-C
float from string. - Number format for an
OCaml
literal floating-point number. - Number format to parse an
OCaml
float from string. - Number format for an
Octave
literal floating-point number. - Number format to parse an
Octave
float from string. - Number format for a
Perl
literal floating-point number. - Number format to parse a
Perl
float from string. - Number format for a
PHP
literal floating-point number. - Number format to parse a
PHP
float from string. - Number format for a
PostgreSQL
literal floating-point number. - Number format for a
Python2
literal floating-point number. - Number format to parse a
Python2
float from string. - Number format for a
Python3
literal floating-point number. - Number format to parse a
Python3
float from string. - Number format for a
Python3.5
or lower literal floating-point number. - Number format for a
Python3.6
or higher literal floating-point number. - Number format for a
Python
literal floating-point number. - Number format to parse a
Python
float from string. - Alias for
MANTISSA_RADIX
. - Alias for
MANTISSA_RADIX_SHIFT
. - Number format for a
ReasonML
literal floating-point number. - Number format to parse a
ReasonML
float from string. - At least 1 digit in the number is required.
- Digits are required after the exponent character. This check will only occur if the exponent character is present.
- Exponent notation is required.
- Positive sign before the exponent is required.
- Digits are required after the decimal point. This check will only occur if the decimal point is present.
- Digits are required before the decimal point.
- Mantissa digits are required (either before or after the decimal point).
- Positive sign before the mantissa is required.
- Number format for a
Ruby
literal floating-point number. - Number format for a
Ruby
literal floating-point number. - Number format to parse a
Ruby
float from string. - Number format for a
Rust
literal floating-point number. - Number format to parse a
Rust
float from string. - Number format for a
R
literal floating-point number. - Number format to parse a
R
float from string. - Number format for a
Sage
literal floating-point number. - Number format to parse a
Sage
float from string. - Number format for a
Scala
literal floating-point number. - Number format to parse a
Scala
float from string. - Any digit separators are allowed in special (non-finite) values.
- Number format for a
SQLite
literal floating-point number. - Standard number format. This is identical to the Rust string format.
- Number format for a
Swift
literal floating-point number. - Number format to parse a
Swift
float from string. - Number format for a
TOML
literal floating-point number. - A digit separator is allowed after any digits.
- Number format for a
Visual Basic
literal floating-point number. - Number format to parse a
Visual Basic
float from string. - Number format for a
XML
literal floating-point number. - Number format for a
YAML
literal floating-point number. - Number format for a
Zig
literal floating-point number. - Number format to parse a
Zig
float from string.
Functions§
- Extract the base prefix character from the format packed struct.
- Extract the base suffix character from the format packed struct.
- Extract the digit separator from the format packed struct.
- Extract the exponent base from the format packed struct. If not provided, defaults to
mantissa_radix
. - Extract the exponent radix from the format packed struct. If not provided, defaults to
mantissa_radix
. - Get the error type from the format packed struct.
- Determine if the format packed struct is valid.
- Determine if the base prefix character is valid.
- Determine if the base suffix character is valid.
- Determine if the digit separator is valid. Digit separators must not be valid digits or sign characters.
- Determine if the provided exponent flags are valid.
- Determine if all of the “punctuation” characters for the options API are valid.
- Determine if all of the “punctuation” characters are valid.
- Determine if the radix is valid.
- Extract the mantissa radix from the format packed struct.
- Extract a generic radix from the format and bitflags.
Type Aliases§
- Type with the exact same size as a
u8
.