mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 00:34:06 +00:00
Update comments for {f16, f32, f64, f128}::midpoint
Clarify what makes some operations not safe, and correct comment in the default branch ("not safe" -> "safe").
This commit is contained in:
parent
e18036c769
commit
43836421f8
@ -851,13 +851,13 @@ impl f128 {
|
||||
// Overflow is impossible
|
||||
(a + b) / 2.
|
||||
} else if abs_a < LO {
|
||||
// Not safe to halve a
|
||||
// Not safe to halve `a` (would underflow)
|
||||
a + (b / 2.)
|
||||
} else if abs_b < LO {
|
||||
// Not safe to halve b
|
||||
// Not safe to halve `b` (would underflow)
|
||||
(a / 2.) + b
|
||||
} else {
|
||||
// Not safe to halve a and b
|
||||
// Safe to halve `a` and `b`
|
||||
(a / 2.) + (b / 2.)
|
||||
}
|
||||
}
|
||||
|
@ -880,13 +880,13 @@ impl f16 {
|
||||
// Overflow is impossible
|
||||
(a + b) / 2.
|
||||
} else if abs_a < LO {
|
||||
// Not safe to halve a
|
||||
// Not safe to halve `a` (would underflow)
|
||||
a + (b / 2.)
|
||||
} else if abs_b < LO {
|
||||
// Not safe to halve b
|
||||
// Not safe to halve `b` (would underflow)
|
||||
(a / 2.) + b
|
||||
} else {
|
||||
// Not safe to halve a and b
|
||||
// Safe to halve `a` and `b`
|
||||
(a / 2.) + (b / 2.)
|
||||
}
|
||||
}
|
||||
|
@ -1070,13 +1070,13 @@ impl f32 {
|
||||
// Overflow is impossible
|
||||
(a + b) / 2.
|
||||
} else if abs_a < LO {
|
||||
// Not safe to halve a
|
||||
// Not safe to halve `a` (would underflow)
|
||||
a + (b / 2.)
|
||||
} else if abs_b < LO {
|
||||
// Not safe to halve b
|
||||
// Not safe to halve `b` (would underflow)
|
||||
(a / 2.) + b
|
||||
} else {
|
||||
// Not safe to halve a and b
|
||||
// Safe to halve `a` and `b`
|
||||
(a / 2.) + (b / 2.)
|
||||
}
|
||||
}
|
||||
|
@ -1064,13 +1064,13 @@ impl f64 {
|
||||
// Overflow is impossible
|
||||
(a + b) / 2.
|
||||
} else if abs_a < LO {
|
||||
// Not safe to halve a
|
||||
// Not safe to halve `a` (would underflow)
|
||||
a + (b / 2.)
|
||||
} else if abs_b < LO {
|
||||
// Not safe to halve b
|
||||
// Not safe to halve `b` (would underflow)
|
||||
(a / 2.) + b
|
||||
} else {
|
||||
// Not safe to halve a and b
|
||||
// Safe to halve `a` and `b`
|
||||
(a / 2.) + (b / 2.)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user