File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88
99// I AM NOT DONE
1010
11+ use std:: f32;
12+
1113fn main ( ) {
12- let x = 1.2331f64 ;
13- let y = 1.2332f64 ;
14- if y != x {
15- println ! ( "Success!" ) ;
16- }
14+ let pi = 3.14f32 ;
15+ let radius = 5.00f32 ;
16+
17+ let area = pi * f32:: powi ( radius, 2 ) ;
18+
19+ println ! (
20+ "The area of a circle with radius {:.2} is {:.5}!" ,
21+ radius, area
22+ )
1723}
Original file line number Diff line number Diff line change @@ -906,15 +906,15 @@ name = "clippy1"
906906path = " exercises/clippy/clippy1.rs"
907907mode = " clippy"
908908hint = """
909- Not every floating point value can be represented exactly in binary values in
910- memory. Take a look at the description of
911- https://doc.rust-lang.org/stable/std/primitive.f32.html
912- When using the binary compare operators with floating points you won't compare
913- the floating point values but the binary representation in memory. This is
914- usually not what you would like to do.
909+ Rust stores the highest precision version of any long or inifinite precision
910+ mathematical constants in the rust standard library.
911+ https://doc.rust-lang.org/stable/std/f32/consts/index.html
912+
913+ We may be tempted to use our own approximations for certain mathematical constants,
914+ but clippy recognizes those imprecise mathematical constants as a source of
915+ potential error.
915916See the suggestions of the clippy warning in compile output and use the
916- machine epsilon value...
917- https://doc.rust-lang.org/stable/std/primitive.f32.html#associatedconstant.EPSILON"""
917+ appropriate replacement constant from std::f32::consts..."""
918918
919919[[exercises ]]
920920name = " clippy2"
You can’t perform that action at this time.
0 commit comments