Skip to content

Commit 19cb6f0

Browse files
committed
Add a default impl for Float::is_subnormal
Any new trait method require a default, or else it's a breaking change.
1 parent 22509ff commit 19cb6f0

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/float.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ pub trait FloatCore: Num + NumCast + Neg<Output = Self> + PartialOrd + Copy {
240240
fn is_normal(self) -> bool {
241241
self.classify() == FpCategory::Normal
242242
}
243-
243+
244244
/// Returns `true` if the number is [subnormal].
245245
///
246246
/// ```
@@ -258,7 +258,8 @@ pub trait FloatCore: Num + NumCast + Neg<Output = Self> + PartialOrd + Copy {
258258
/// // Values between `0` and `min` are Subnormal.
259259
/// assert!(lower_than_min.is_subnormal());
260260
/// ```
261-
/// [subnormal]: https://en.wikipedia.org/wiki/Denormal_number
261+
/// [subnormal]: https://en.wikipedia.org/wiki/Subnormal_number
262+
#[inline]
262263
fn is_subnormal(self) -> bool {
263264
self.classify() == FpCategory::Subnormal
264265
}
@@ -1146,7 +1147,7 @@ pub trait Float: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
11461147
/// // Values between `0` and `min` are Subnormal.
11471148
/// assert!(!lower_than_min.is_normal());
11481149
/// ```
1149-
/// [subnormal]: http://en.wikipedia.org/wiki/Denormal_number
1150+
/// [subnormal]: http://en.wikipedia.org/wiki/Subnormal_number
11501151
fn is_normal(self) -> bool;
11511152

11521153
/// Returns `true` if the number is [subnormal].
@@ -1166,8 +1167,11 @@ pub trait Float: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
11661167
/// // Values between `0` and `min` are Subnormal.
11671168
/// assert!(lower_than_min.is_subnormal());
11681169
/// ```
1169-
/// [subnormal]: https://en.wikipedia.org/wiki/Denormal_number
1170-
fn is_subnormal(self) -> bool;
1170+
/// [subnormal]: https://en.wikipedia.org/wiki/Subnormal_number
1171+
#[inline]
1172+
fn is_subnormal(self) -> bool {
1173+
self.classify() == FpCategory::Subnormal
1174+
}
11711175

11721176
/// Returns the floating point category of the number. If only one property
11731177
/// is going to be tested, it is generally faster to use the specific

0 commit comments

Comments
 (0)