File tree Expand file tree Collapse file tree 2 files changed +26
-24
lines changed Expand file tree Collapse file tree 2 files changed +26
-24
lines changed Original file line number Diff line number Diff line change @@ -551,9 +551,22 @@ impl Float for f32 {
551551 #[ inline( always) ]
552552 fn neg_zero ( ) -> f32 { -0.0 }
553553
554+ /// Returns `true` if the number is NaN
554555 #[ inline( always) ]
555556 fn is_NaN ( & self ) -> bool { * self != * self }
556557
558+ /// Returns `true` if the number is infinite
559+ #[ inline( always) ]
560+ fn is_infinite ( & self ) -> bool {
561+ * self == Float :: infinity ( ) || * self == Float :: neg_infinity ( )
562+ }
563+
564+ /// Returns `true` if the number is not infinite or NaN
565+ #[ inline( always) ]
566+ fn is_finite ( & self ) -> bool {
567+ !( self . is_NaN ( ) || self . is_infinite ( ) )
568+ }
569+
557570 #[ inline( always) ]
558571 fn mantissa_digits ( ) -> uint { 24 }
559572
@@ -575,18 +588,6 @@ impl Float for f32 {
575588 #[ inline( always) ]
576589 fn max_10_exp ( ) -> int { 38 }
577590
578- /// Returns `true` if the number is infinite
579- #[ inline( always) ]
580- fn is_infinite ( & self ) -> bool {
581- * self == Float :: infinity ( ) || * self == Float :: neg_infinity ( )
582- }
583-
584- /// Returns `true` if the number is finite
585- #[ inline( always) ]
586- fn is_finite ( & self ) -> bool {
587- !( self . is_NaN ( ) || self . is_infinite ( ) )
588- }
589-
590591 ///
591592 /// Returns the exponential of the number, minus `1`, in a way that is accurate
592593 /// even if the number is close to zero
Original file line number Diff line number Diff line change @@ -784,9 +784,22 @@ impl Float for float {
784784 #[inline(always)]
785785 fn neg_zero() -> float { -0.0 }
786786
787+ /// Returns `true` if the number is NaN
787788 #[inline(always)]
788789 fn is_NaN(&self) -> bool { *self != *self }
789790
791+ /// Returns `true` if the number is infinite
792+ #[inline(always)]
793+ fn is_infinite(&self) -> bool {
794+ *self == Float::infinity() || *self == Float::neg_infinity()
795+ }
796+
797+ /// Returns `true` if the number is not infinite or NaN
798+ #[inline(always)]
799+ fn is_finite(&self) -> bool {
800+ !(self.is_NaN() || self.is_infinite())
801+ }
802+
790803 #[inline(always)]
791804 fn mantissa_digits() -> uint { Float::mantissa_digits::<f64>() }
792805
@@ -808,18 +821,6 @@ impl Float for float {
808821 #[inline(always)]
809822 fn max_10_exp() -> int { Float::max_10_exp::<f64>() }
810823
811- /// Returns `true` if the number is infinite
812- #[inline(always)]
813- fn is_infinite(&self) -> bool {
814- *self == Float::infinity() || *self == Float::neg_infinity()
815- }
816-
817- /// Returns `true` if the number is finite
818- #[inline(always)]
819- fn is_finite(&self) -> bool {
820- !(self.is_NaN() || self.is_infinite())
821- }
822-
823824 ///
824825 /// Returns the exponential of the number, minus `1`, in a way that is accurate
825826 /// even if the number is close to zero
You can’t perform that action at this time.
0 commit comments