Re:Announcing Rust 1.20
by tomjakubowski on Thursday August 31, 2017 @02:30PM
(#15142611)
GLSL programmers may rejoice in learning that `1.` is accepted syntax too.
Having used Rust since pre-release I'm slightly embarrassed that I'm only learning about this today.
Re:Announcing Rust 1.20
by ComputerGuru on Friday September 01, 2017 @11:27AM
(#15149243)
That's ok. I presume you weren't a C/C++ dev before, that's old school shorthand for C coders that don't want to type out suffixes or cast numeric values.
Re:Announcing Rust 1.20
by steveklabnik on Thursday August 31, 2017 @02:26PM
(#15142577)
> I imagine the OP is using them for maximum explicitness
I used them because that's the style that was used inside of std::f32;
const INFINITY: f32 = 1.0 / 0.0;
totally works.
Nope. `f32` is for single-precision floats, and `f64` is for double-precision floats. There have been some people lobbying for `f16` and `f128` as well.
Also, you don't need to use those suffixes. I imagine the OP is using them for maximum explicitness, but you can just write `1.0` and it will be inferred to a floating-point type as necessary (contrast `1`, which will be inferred to an integral type).