Expand description
§Hexponent
Hexponent is a hexadecimal literal parser for Rust based on the C11 specification section 6.4.4.2.
use hexponent::FloatLiteral;
let float_repr: FloatLiteral = "0x3.4".parse().unwrap();
let value = float_repr.convert::<f32>().inner();
assert_eq!(value, 3.25);Hexponent has a minimum supported rust version of 1.34.
§Features
- No dependencies
- Non-UTF-8 parser
- Precision warnings
no_stdsupport (MSRV 1.36.0)
§Differences from the specification
There are two places where hexponent differs from the C11 specificaiton.
- An exponent is not required. (
0x1.2is allowed) floating-suffixis not parsed. (0x1p4lis not allowed)
§no_std support
no_std support can be enabled by disabling the default std feature for
hexponent in your Cargo.toml.
hexponent = {version = "0.2", default-features = false}no_std support is only possible in rustc version 1.36.0 and higher.
Disabling the std feature currently only disables the std::error::Error
implementation for ParseError.
Structs§
- Float
Literal - Represents a floating point literal
- Parse
Error - Error type for parsing hexadecimal literals.
Enums§
- Conversion
Result - Indicates the preicsision of a conversion
- Parse
Error Kind - Kind of parsing error.
Traits§
- FPFormat
- Trait to describe conversion to floating point formats.