@@ -285,20 +285,16 @@ impl Signed for f32 {
285
285
#[ inline]
286
286
fn abs ( & self ) -> f32 { abs ( * self ) }
287
287
288
- ///
289
288
/// The positive difference of two numbers. Returns `0.0` if the number is less than or
290
289
/// equal to `other`, otherwise the difference between`self` and `other` is returned.
291
- ///
292
290
#[ inline]
293
291
fn abs_sub ( & self , other : & f32 ) -> f32 { abs_sub ( * self , * other) }
294
292
295
- ///
296
293
/// # Returns
297
294
///
298
295
/// - `1.0` if the number is positive, `+0.0` or `INFINITY`
299
296
/// - `-1.0` if the number is negative, `-0.0` or `NEG_INFINITY`
300
297
/// - `NAN` if the number is NaN
301
- ///
302
298
#[ inline]
303
299
fn signum ( & self ) -> f32 {
304
300
if self . is_nan ( ) { NAN } else { copysign ( 1.0 , * self ) }
@@ -330,14 +326,12 @@ impl Round for f32 {
330
326
#[ inline]
331
327
fn trunc ( & self ) -> f32 { trunc ( * self ) }
332
328
333
- ///
334
329
/// The fractional part of the number, satisfying:
335
330
///
336
331
/// ```rust
337
332
/// let x = 1.65f32;
338
333
/// assert!(x == x.trunc() + x.fract())
339
334
/// ```
340
- ///
341
335
#[ inline]
342
336
fn fract ( & self ) -> f32 { * self - self . trunc ( ) }
343
337
}
@@ -490,15 +484,13 @@ impl Real for f32 {
490
484
#[ inline]
491
485
fn tanh ( & self ) -> f32 { tanh ( * self ) }
492
486
493
- ///
494
487
/// Inverse hyperbolic sine
495
488
///
496
489
/// # Returns
497
490
///
498
491
/// - on success, the inverse hyperbolic sine of `self` will be returned
499
492
/// - `self` if `self` is `0.0`, `-0.0`, `INFINITY`, or `NEG_INFINITY`
500
493
/// - `NAN` if `self` is `NAN`
501
- ///
502
494
#[ inline]
503
495
fn asinh ( & self ) -> f32 {
504
496
match * self {
@@ -507,15 +499,13 @@ impl Real for f32 {
507
499
}
508
500
}
509
501
510
- ///
511
502
/// Inverse hyperbolic cosine
512
503
///
513
504
/// # Returns
514
505
///
515
506
/// - on success, the inverse hyperbolic cosine of `self` will be returned
516
507
/// - `INFINITY` if `self` is `INFINITY`
517
508
/// - `NAN` if `self` is `NAN` or `self < 1.0` (including `NEG_INFINITY`)
518
- ///
519
509
#[ inline]
520
510
fn acosh ( & self ) -> f32 {
521
511
match * self {
@@ -524,7 +514,6 @@ impl Real for f32 {
524
514
}
525
515
}
526
516
527
- ///
528
517
/// Inverse hyperbolic tangent
529
518
///
530
519
/// # Returns
@@ -535,7 +524,6 @@ impl Real for f32 {
535
524
/// - `NEG_INFINITY` if `self` is `-1.0`
536
525
/// - `NAN` if the `self` is `NAN` or outside the domain of `-1.0 <= self <= 1.0`
537
526
/// (including `INFINITY` and `NEG_INFINITY`)
538
- ///
539
527
#[ inline]
540
528
fn atanh ( & self ) -> f32 {
541
529
0.5 * ( ( 2.0 * * self ) / ( 1.0 - * self ) ) . ln_1p ( )
@@ -643,38 +631,30 @@ impl Float for f32 {
643
631
ldexp ( x, exp as c_int )
644
632
}
645
633
646
- ///
647
634
/// Breaks the number into a normalized fraction and a base-2 exponent, satisfying:
648
635
///
649
636
/// - `self = x * pow(2, exp)`
650
637
/// - `0.5 <= abs(x) < 1.0`
651
- ///
652
638
#[ inline]
653
639
fn frexp ( & self ) -> ( f32 , int ) {
654
640
let mut exp = 0 ;
655
641
let x = frexp ( * self , & mut exp) ;
656
642
( x, exp as int )
657
643
}
658
644
659
- ///
660
645
/// Returns the exponential of the number, minus `1`, in a way that is accurate
661
646
/// even if the number is close to zero
662
- ///
663
647
#[ inline]
664
648
fn exp_m1 ( & self ) -> f32 { exp_m1 ( * self ) }
665
649
666
- ///
667
650
/// Returns the natural logarithm of the number plus `1` (`ln(1+n)`) more accurately
668
651
/// than if the operations were performed separately
669
- ///
670
652
#[ inline]
671
653
fn ln_1p ( & self ) -> f32 { ln_1p ( * self ) }
672
654
673
- ///
674
655
/// Fused multiply-add. Computes `(self * a) + b` with only one rounding error. This
675
656
/// produces a more accurate result with better performance than a separate multiplication
676
657
/// operation followed by an add.
677
- ///
678
658
#[ inline]
679
659
fn mul_add ( & self , a : f32 , b : f32 ) -> f32 {
680
660
mul_add ( * self , a, b)
@@ -708,82 +688,71 @@ impl Float for f32 {
708
688
// Section: String Conversions
709
689
//
710
690
711
- ///
712
691
/// Converts a float to a string
713
692
///
714
693
/// # Arguments
715
694
///
716
695
/// * num - The float value
717
- ///
718
696
#[ inline]
719
697
pub fn to_str ( num : f32 ) -> ~str {
720
698
let ( r, _) = strconv:: float_to_str_common (
721
699
num, 10 u, true , strconv:: SignNeg , strconv:: DigAll , strconv:: ExpNone , false ) ;
722
700
r
723
701
}
724
702
725
- ///
726
703
/// Converts a float to a string in hexadecimal format
727
704
///
728
705
/// # Arguments
729
706
///
730
707
/// * num - The float value
731
- ///
732
708
#[ inline]
733
709
pub fn to_str_hex ( num : f32 ) -> ~str {
734
710
let ( r, _) = strconv:: float_to_str_common (
735
711
num, 16 u, true , strconv:: SignNeg , strconv:: DigAll , strconv:: ExpNone , false ) ;
736
712
r
737
713
}
738
714
739
- ///
740
715
/// Converts a float to a string in a given radix, and a flag indicating
741
716
/// whether it's a special value
742
717
///
743
718
/// # Arguments
744
719
///
745
720
/// * num - The float value
746
721
/// * radix - The base to use
747
- ///
748
722
#[ inline]
749
723
pub fn to_str_radix_special ( num : f32 , rdx : uint ) -> ( ~str , bool ) {
750
724
strconv:: float_to_str_common ( num, rdx, true ,
751
725
strconv:: SignNeg , strconv:: DigAll , strconv:: ExpNone , false )
752
726
}
753
727
754
- ///
755
728
/// Converts a float to a string with exactly the number of
756
729
/// provided significant digits
757
730
///
758
731
/// # Arguments
759
732
///
760
733
/// * num - The float value
761
734
/// * digits - The number of significant digits
762
- ///
763
735
#[ inline]
764
736
pub fn to_str_exact ( num : f32 , dig : uint ) -> ~str {
765
737
let ( r, _) = strconv:: float_to_str_common (
766
738
num, 10 u, true , strconv:: SignNeg , strconv:: DigExact ( dig) , strconv:: ExpNone , false ) ;
767
739
r
768
740
}
769
741
770
- ///
771
742
/// Converts a float to a string with a maximum number of
772
743
/// significant digits
773
744
///
774
745
/// # Arguments
775
746
///
776
747
/// * num - The float value
777
748
/// * digits - The number of significant digits
778
- ///
779
749
#[ inline]
780
750
pub fn to_str_digits ( num : f32 , dig : uint ) -> ~str {
781
751
let ( r, _) = strconv:: float_to_str_common (
782
752
num, 10 u, true , strconv:: SignNeg , strconv:: DigMax ( dig) , strconv:: ExpNone , false ) ;
783
753
r
784
754
}
785
755
786
- ///
787
756
/// Converts a float to a string using the exponential notation with exactly the number of
788
757
/// provided digits after the decimal point in the significand
789
758
///
@@ -792,15 +761,13 @@ pub fn to_str_digits(num: f32, dig: uint) -> ~str {
792
761
/// * num - The float value
793
762
/// * digits - The number of digits after the decimal point
794
763
/// * upper - Use `E` instead of `e` for the exponent sign
795
- ///
796
764
#[ inline]
797
765
pub fn to_str_exp_exact ( num : f32 , dig : uint , upper : bool ) -> ~str {
798
766
let ( r, _) = strconv:: float_to_str_common (
799
767
num, 10 u, true , strconv:: SignNeg , strconv:: DigExact ( dig) , strconv:: ExpDec , upper) ;
800
768
r
801
769
}
802
770
803
- ///
804
771
/// Converts a float to a string using the exponential notation with the maximum number of
805
772
/// digits after the decimal point in the significand
806
773
///
@@ -809,7 +776,6 @@ pub fn to_str_exp_exact(num: f32, dig: uint, upper: bool) -> ~str {
809
776
/// * num - The float value
810
777
/// * digits - The number of digits after the decimal point
811
778
/// * upper - Use `E` instead of `e` for the exponent sign
812
- ///
813
779
#[ inline]
814
780
pub fn to_str_exp_digits ( num : f32 , dig : uint , upper : bool ) -> ~str {
815
781
let ( r, _) = strconv:: float_to_str_common (
@@ -845,7 +811,6 @@ impl num::ToStrRadix for f32 {
845
811
}
846
812
}
847
813
848
- ///
849
814
/// Convert a string in base 16 to a float.
850
815
/// Accepts a optional binary exponent.
851
816
///
@@ -871,15 +836,13 @@ impl num::ToStrRadix for f32 {
871
836
///
872
837
/// `None` if the string did not represent a valid number. Otherwise,
873
838
/// `Some(n)` where `n` is the floating-point number represented by `[num]`.
874
- ///
875
839
#[ inline]
876
840
pub fn from_str_hex ( num : & str ) -> Option < f32 > {
877
841
strconv:: from_str_common ( num, 16 u, true , true , true ,
878
842
strconv:: ExpBin , false , false )
879
843
}
880
844
881
845
impl FromStr for f32 {
882
- ///
883
846
/// Convert a string in base 10 to a float.
884
847
/// Accepts a optional decimal exponent.
885
848
///
@@ -905,7 +868,6 @@ impl FromStr for f32 {
905
868
///
906
869
/// `None` if the string did not represent a valid number. Otherwise,
907
870
/// `Some(n)` where `n` is the floating-point number represented by `num`.
908
- ///
909
871
#[ inline]
910
872
fn from_str ( val : & str ) -> Option < f32 > {
911
873
strconv:: from_str_common ( val, 10 u, true , true , true ,
@@ -914,7 +876,6 @@ impl FromStr for f32 {
914
876
}
915
877
916
878
impl num:: FromStrRadix for f32 {
917
- ///
918
879
/// Convert a string in an given base to a float.
919
880
///
920
881
/// Due to possible conflicts, this function does **not** accept
@@ -932,7 +893,6 @@ impl num::FromStrRadix for f32 {
932
893
///
933
894
/// `None` if the string did not represent a valid number. Otherwise,
934
895
/// `Some(n)` where `n` is the floating-point number represented by `num`.
935
- ///
936
896
#[ inline]
937
897
fn from_str_radix ( val : & str , rdx : uint ) -> Option < f32 > {
938
898
strconv:: from_str_common ( val, rdx, true , true , false ,
0 commit comments