File tree Expand file tree Collapse file tree 4 files changed +16
-4
lines changed
Expand file tree Collapse file tree 4 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -1236,7 +1236,8 @@ impl f128 {
12361236 /// less than `min`. Otherwise this returns `self`.
12371237 ///
12381238 /// Note that this function returns NaN if the initial value was NaN as
1239- /// well.
1239+ /// well. Furthermore, as usual for floating point comparisons, `-0.0` and `+0.0`
1240+ /// are considered equal.
12401241 ///
12411242 /// # Panics
12421243 ///
@@ -1253,6 +1254,8 @@ impl f128 {
12531254 /// assert!((0.0f128).clamp(-2.0, 1.0) == 0.0);
12541255 /// assert!((2.0f128).clamp(-2.0, 1.0) == 1.0);
12551256 /// assert!((f128::NAN).clamp(-2.0, 1.0).is_nan());
1257+ /// // `0.0` is considered to be neither less than nor greater than `-0.0`.
1258+ /// assert!((0.0f128).clamp(-0.0, -0.0).is_sign_positive());
12561259 /// # }
12571260 /// ```
12581261 #[ inline]
Original file line number Diff line number Diff line change @@ -1215,7 +1215,8 @@ impl f16 {
12151215 /// less than `min`. Otherwise this returns `self`.
12161216 ///
12171217 /// Note that this function returns NaN if the initial value was NaN as
1218- /// well.
1218+ /// well. Furthermore, as usual for floating point comparisons, `-0.0` and `+0.0`
1219+ /// are considered equal.
12191220 ///
12201221 /// # Panics
12211222 ///
@@ -1231,6 +1232,8 @@ impl f16 {
12311232 /// assert!((0.0f16).clamp(-2.0, 1.0) == 0.0);
12321233 /// assert!((2.0f16).clamp(-2.0, 1.0) == 1.0);
12331234 /// assert!((f16::NAN).clamp(-2.0, 1.0).is_nan());
1235+ /// // `0.0` is considered to be neither less than nor greater than `-0.0`.
1236+ /// assert!((0.0f16).clamp(-0.0, -0.0).is_sign_positive());
12341237 /// # }
12351238 /// ```
12361239 #[ inline]
Original file line number Diff line number Diff line change @@ -1395,7 +1395,8 @@ impl f32 {
13951395 /// less than `min`. Otherwise this returns `self`.
13961396 ///
13971397 /// Note that this function returns NaN if the initial value was NaN as
1398- /// well.
1398+ /// well. Furthermore, as usual for floating point comparisons, `-0.0` and `+0.0`
1399+ /// are considered equal.
13991400 ///
14001401 /// # Panics
14011402 ///
@@ -1408,6 +1409,8 @@ impl f32 {
14081409 /// assert!((0.0f32).clamp(-2.0, 1.0) == 0.0);
14091410 /// assert!((2.0f32).clamp(-2.0, 1.0) == 1.0);
14101411 /// assert!((f32::NAN).clamp(-2.0, 1.0).is_nan());
1412+ /// // `0.0` is considered to be neither less than nor greater than `-0.0`.
1413+ /// assert!((0.0f32).clamp(-0.0, -0.0).is_sign_positive());
14111414 /// ```
14121415 #[ must_use = "method returns a new number and does not mutate the original value" ]
14131416 #[ stable( feature = "clamp" , since = "1.50.0" ) ]
Original file line number Diff line number Diff line change @@ -1393,7 +1393,8 @@ impl f64 {
13931393 /// less than `min`. Otherwise this returns `self`.
13941394 ///
13951395 /// Note that this function returns NaN if the initial value was NaN as
1396- /// well.
1396+ /// well. Furthermore, as usual for floating point comparisons, `-0.0` and `+0.0`
1397+ /// are considered equal.
13971398 ///
13981399 /// # Panics
13991400 ///
@@ -1406,6 +1407,8 @@ impl f64 {
14061407 /// assert!((0.0f64).clamp(-2.0, 1.0) == 0.0);
14071408 /// assert!((2.0f64).clamp(-2.0, 1.0) == 1.0);
14081409 /// assert!((f64::NAN).clamp(-2.0, 1.0).is_nan());
1410+ /// // `0.0` is considered to be neither less than nor greater than `-0.0`.
1411+ /// assert!((0.0f64).clamp(-0.0, -0.0).is_sign_positive());
14091412 /// ```
14101413 #[ must_use = "method returns a new number and does not mutate the original value" ]
14111414 #[ stable( feature = "clamp" , since = "1.50.0" ) ]
You can’t perform that action at this time.
0 commit comments