@@ -236,7 +236,7 @@ impl f32 {
236
236
/// let b = 60.0_f32;
237
237
///
238
238
/// // 100.0
239
- /// let abs_difference = (m.mul_add(x, b) - (m*x + b)).abs();
239
+ /// let abs_difference = (m.mul_add(x, b) - ((m * x) + b)).abs();
240
240
///
241
241
/// assert!(abs_difference <= f32::EPSILON);
242
242
/// ```
@@ -318,7 +318,7 @@ impl f32 {
318
318
/// use std::f32;
319
319
///
320
320
/// let x = 2.0_f32;
321
- /// let abs_difference = (x.powi(2) - x*x ).abs();
321
+ /// let abs_difference = (x.powi(2) - (x * x) ).abs();
322
322
///
323
323
/// assert!(abs_difference <= f32::EPSILON);
324
324
/// ```
@@ -336,7 +336,7 @@ impl f32 {
336
336
/// use std::f32;
337
337
///
338
338
/// let x = 2.0_f32;
339
- /// let abs_difference = (x.powf(2.0) - x*x ).abs();
339
+ /// let abs_difference = (x.powf(2.0) - (x * x) ).abs();
340
340
///
341
341
/// assert!(abs_difference <= f32::EPSILON);
342
342
/// ```
@@ -600,7 +600,7 @@ impl f32 {
600
600
/// ```
601
601
/// use std::f32;
602
602
///
603
- /// let x = f32::consts::PI/2.0 ;
603
+ /// let x = f32::consts::FRAC_PI_2 ;
604
604
///
605
605
/// let abs_difference = (x.sin() - 1.0).abs();
606
606
///
@@ -623,7 +623,7 @@ impl f32 {
623
623
/// ```
624
624
/// use std::f32;
625
625
///
626
- /// let x = 2.0* f32::consts::PI;
626
+ /// let x = 2.0 * f32::consts::PI;
627
627
///
628
628
/// let abs_difference = (x.cos() - 1.0).abs();
629
629
///
@@ -646,7 +646,7 @@ impl f32 {
646
646
/// ```
647
647
/// use std::f32;
648
648
///
649
- /// let x = f32::consts::PI / 4.0 ;
649
+ /// let x = f32::consts::FRAC_PI_4 ;
650
650
/// let abs_difference = (x.tan() - 1.0).abs();
651
651
///
652
652
/// assert!(abs_difference <= f32::EPSILON);
@@ -666,10 +666,10 @@ impl f32 {
666
666
/// ```
667
667
/// use std::f32;
668
668
///
669
- /// let f = f32::consts::PI / 2.0 ;
669
+ /// let f = f32::consts::FRAC_PI_2 ;
670
670
///
671
671
/// // asin(sin(pi/2))
672
- /// let abs_difference = (f.sin().asin() - f32::consts::PI / 2.0 ).abs();
672
+ /// let abs_difference = (f.sin().asin() - f32::consts::FRAC_PI_2 ).abs();
673
673
///
674
674
/// assert!(abs_difference <= f32::EPSILON);
675
675
/// ```
@@ -688,10 +688,10 @@ impl f32 {
688
688
/// ```
689
689
/// use std::f32;
690
690
///
691
- /// let f = f32::consts::PI / 4.0 ;
691
+ /// let f = f32::consts::FRAC_PI_4 ;
692
692
///
693
693
/// // acos(cos(pi/4))
694
- /// let abs_difference = (f.cos().acos() - f32::consts::PI / 4.0 ).abs();
694
+ /// let abs_difference = (f.cos().acos() - f32::consts::FRAC_PI_4 ).abs();
695
695
///
696
696
/// assert!(abs_difference <= f32::EPSILON);
697
697
/// ```
@@ -734,7 +734,6 @@ impl f32 {
734
734
/// ```
735
735
/// use std::f32;
736
736
///
737
- /// let pi = f32::consts::PI;
738
737
/// // Positive angles measured counter-clockwise
739
738
/// // from positive x axis
740
739
/// // -pi/4 radians (45 deg clockwise)
@@ -745,8 +744,8 @@ impl f32 {
745
744
/// let x2 = -3.0f32;
746
745
/// let y2 = 3.0f32;
747
746
///
748
- /// let abs_difference_1 = (y1.atan2(x1) - (-pi/4.0 )).abs();
749
- /// let abs_difference_2 = (y2.atan2(x2) - 3.0*pi/4.0 ).abs();
747
+ /// let abs_difference_1 = (y1.atan2(x1) - (-f32::consts::FRAC_PI_4 )).abs();
748
+ /// let abs_difference_2 = (y2.atan2(x2) - ( 3.0 * f32::consts::FRAC_PI_4) ).abs();
750
749
///
751
750
/// assert!(abs_difference_1 <= f32::EPSILON);
752
751
/// assert!(abs_difference_2 <= f32::EPSILON);
@@ -765,7 +764,7 @@ impl f32 {
765
764
/// ```
766
765
/// use std::f32;
767
766
///
768
- /// let x = f32::consts::PI/4.0 ;
767
+ /// let x = f32::consts::FRAC_PI_4 ;
769
768
/// let f = x.sin_cos();
770
769
///
771
770
/// let abs_difference_0 = (f.0 - x.sin()).abs();
@@ -834,7 +833,7 @@ impl f32 {
834
833
///
835
834
/// let f = x.sinh();
836
835
/// // Solving sinh() at 1 gives `(e^2-1)/(2e)`
837
- /// let g = (e*e - 1.0)/ (2.0* e);
836
+ /// let g = ((e * e) - 1.0) / (2.0 * e);
838
837
/// let abs_difference = (f - g).abs();
839
838
///
840
839
/// assert!(abs_difference <= f32::EPSILON);
@@ -856,7 +855,7 @@ impl f32 {
856
855
/// let x = 1.0f32;
857
856
/// let f = x.cosh();
858
857
/// // Solving cosh() at 1 gives this result
859
- /// let g = (e*e + 1.0)/ (2.0* e);
858
+ /// let g = ((e * e) + 1.0) / (2.0 * e);
860
859
/// let abs_difference = (f - g).abs();
861
860
///
862
861
/// // Same result
@@ -880,7 +879,7 @@ impl f32 {
880
879
///
881
880
/// let f = x.tanh();
882
881
/// // Solving tanh() at 1 gives `(1 - e^(-2))/(1 + e^(-2))`
883
- /// let g = (1.0 - e.powi(-2))/ (1.0 + e.powi(-2));
882
+ /// let g = (1.0 - e.powi(-2)) / (1.0 + e.powi(-2));
884
883
/// let abs_difference = (f - g).abs();
885
884
///
886
885
/// assert!(abs_difference <= f32::EPSILON);
0 commit comments