Crate hexf_parse

source ·
Expand description

Parses hexadecimal float literals. There are two functions parse_hexf32 and parse_hexf64 provided for each type.

use hexf_parse::*;
assert_eq!(parse_hexf32("0x1.99999ap-4", false), Ok(0.1f32));
assert_eq!(parse_hexf64("0x1.999999999999ap-4", false), Ok(0.1f64));

An additional bool parameter can be set to true if you want to allow underscores.

use hexf_parse::*;
assert!(parse_hexf64("0x0.1_7p8", false).is_err());
assert_eq!(parse_hexf64("0x0.1_7p8", true), Ok(23.0f64));

The error is reported via an opaque ParseHexfError type.

Structs

  • An opaque error type from parse_hexf32 and parse_hexf64.

Functions

  • Tries to parse a hexadecimal float literal to f32. The underscore is allowed only when allow_underscore is true.
  • Tries to parse a hexadecimal float literal to f64. The underscore is allowed only when allow_underscore is true.