How can I initialize a variable of type f64
with the maximum possible value? I already tried things like:
std::f64::MAX
f64::MAX_VALUE
f64::consts::MAX_VALUE
core::f64::MAX_VALUE
and some other variants but the compiler always complains about an unresolved name. I'm using no namespaces (like no use xx::yyy
) and I'm trying to initialize the variable like this:
let mut min = f64::consts::MAX_VALUE;
Did I miss something or is there no way to get the largest possible value for a f64?
If there is a way for f64
, what are the ways for the other data types?
According to the std::f64
module documentation, the following should be what you want:
std::f64::MAX
which is declared as:
pub const MAX: f64 = 1.7976931348623157e+308_f64
It can be used like:
fn main() {
let mut min = std::f64::MAX;
}
I found this by searching Google for "f64 maximum value rust".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With