File tree Expand file tree Collapse file tree 2 files changed +19
-13
lines changed Expand file tree Collapse file tree 2 files changed +19
-13
lines changed Original file line number Diff line number Diff line change 8
8
9
9
// I AM NOT DONE
10
10
11
+ use std:: f32;
12
+
11
13
fn 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
+ )
17
23
}
Original file line number Diff line number Diff line change @@ -906,15 +906,15 @@ name = "clippy1"
906
906
path = " exercises/clippy/clippy1.rs"
907
907
mode = " clippy"
908
908
hint = """
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.
915
916
See 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..."""
918
918
919
919
[[exercises ]]
920
920
name = " clippy2"
You can’t perform that action at this time.
0 commit comments