Constants
As great as it is to know what happens under the hood, it would be nice to have convenient ways to...
- check what is the difference in precision for Pi as an
f32
vs anf64
- see what the minimum or maximum value for a given type is, like
i128
oru128
. - represent
infinity
ornegative infinity
orNaN
That's where constants come in.
fun fact: in the source code,
NAN
is represented as0.0_f32 / 0.0_f32
,INFINITY
as1.0_f32 / 0.0_f32
, andNEG_INFINITY
as-1.0_f32 / 0.0_f32
. Dividing by zero appears to have its uses :)
#![allow(unused)] fn main() { //TODO: Add examples }
Check a given type's documentation to see what kind of constants they have available.
For example, std::i128
and std::f32