7 releases

0.3.1 Jul 3, 2020
0.3.0 Apr 21, 2020
0.2.3 Mar 21, 2020
0.1.0 Feb 24, 2020

#1537 in Parser implementations

Download history 17/week @ 2024-04-08 28/week @ 2024-04-15 24/week @ 2024-04-22 23/week @ 2024-04-29 24/week @ 2024-05-06 31/week @ 2024-05-13 24/week @ 2024-05-20 23/week @ 2024-05-27 67/week @ 2024-06-03 29/week @ 2024-06-10 24/week @ 2024-06-17 28/week @ 2024-06-24 15/week @ 2024-07-01 52/week @ 2024-07-08 73/week @ 2024-07-15 70/week @ 2024-07-22

214 downloads per month
Used in 4 crates (2 directly)

MIT/Apache

27KB
510 lines

Hexponent

A library to parse hexadecimal floating point numbers.

Documentation

Documentation can be found at https://docs.rs/hexponent/

Todo

See issues

License

Licensed under either of

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


lib.rs:

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_std support (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.2 is allowed)
  • floating-suffix is not parsed. (0x1p4l is 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.

No runtime deps