Skip to content

The double-int format represents an integer that can be stored in an IEEE 754 double-precision number without loss of precision

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

x52dev/double-int

Repository files navigation

double-int

crates.io Documentation dependency status MIT or Apache 2.0 licensed
CI codecov Version Download

The double-int format represents an integer that can be stored in an IEEE 754 double-precision number without loss of precision.

This crate has been designed for use with OpenAPI tooling that wish to support integer-based format: double-int fields. See docs in the OpenAPI format registry.

Examples

#[derive(Debug, serde::Deserialize)]
struct Config {
    count: DoubleInt,
}

let config = toml::from_str::<Config>(r#"
    count = 42
"#).unwrap();
assert_eq!(config.count, 42);

let config = toml::from_str::<Config>(r#"
    count = -42
"#).unwrap();
assert_eq!(config.count, -42);

// count is outside the bounds of a double-int (> 2^53 in this case)
// (this would usually be accepted by an i64)
let config = toml::from_str::<Config>(r#"
    count = 36028797018963968
"#).unwrap_err();

About

The double-int format represents an integer that can be stored in an IEEE 754 double-precision number without loss of precision

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Sponsor this project