mirror of
https://github.com/rust-lang/rust
synced 2024-10-02 23:04:50 +00:00
Reword docs for f32
and f64
Better explain the reasoning for the `next_up`/`next_down` integer implementation, as requested by Ralf.
This commit is contained in:
parent
fce07a82c6
commit
0314fe62bd
|
@ -796,8 +796,9 @@ pub const fn is_sign_negative(self) -> bool {
|
|||
#[unstable(feature = "float_next_up_down", issue = "91399")]
|
||||
#[rustc_const_unstable(feature = "float_next_up_down", issue = "91399")]
|
||||
pub const fn next_up(self) -> Self {
|
||||
// We must use strictly integer arithmetic to prevent denormals from
|
||||
// flushing to zero after an arithmetic operation on some platforms.
|
||||
// Some targets violate Rust's assumption of IEEE semantics, e.g. by flushing
|
||||
// denormals to zero. This is in general unsound and unsupported, but here
|
||||
// we do our best to still produce the correct result on such targets.
|
||||
let bits = self.to_bits();
|
||||
if self.is_nan() || bits == Self::INFINITY.to_bits() {
|
||||
return self;
|
||||
|
@ -843,8 +844,9 @@ pub const fn next_up(self) -> Self {
|
|||
#[unstable(feature = "float_next_up_down", issue = "91399")]
|
||||
#[rustc_const_unstable(feature = "float_next_up_down", issue = "91399")]
|
||||
pub const fn next_down(self) -> Self {
|
||||
// We must use strictly integer arithmetic to prevent denormals from
|
||||
// flushing to zero after an arithmetic operation on some platforms.
|
||||
// Some targets violate Rust's assumption of IEEE semantics, e.g. by flushing
|
||||
// denormals to zero. This is in general unsound and unsupported, but here
|
||||
// we do our best to still produce the correct result on such targets.
|
||||
let bits = self.to_bits();
|
||||
if self.is_nan() || bits == Self::NEG_INFINITY.to_bits() {
|
||||
return self;
|
||||
|
|
|
@ -804,8 +804,9 @@ pub fn is_negative(self) -> bool {
|
|||
#[unstable(feature = "float_next_up_down", issue = "91399")]
|
||||
#[rustc_const_unstable(feature = "float_next_up_down", issue = "91399")]
|
||||
pub const fn next_up(self) -> Self {
|
||||
// We must use strictly integer arithmetic to prevent denormals from
|
||||
// flushing to zero after an arithmetic operation on some platforms.
|
||||
// Some targets violate Rust's assumption of IEEE semantics, e.g. by flushing
|
||||
// denormals to zero. This is in general unsound and unsupported, but here
|
||||
// we do our best to still produce the correct result on such targets.
|
||||
let bits = self.to_bits();
|
||||
if self.is_nan() || bits == Self::INFINITY.to_bits() {
|
||||
return self;
|
||||
|
@ -851,8 +852,9 @@ pub const fn next_up(self) -> Self {
|
|||
#[unstable(feature = "float_next_up_down", issue = "91399")]
|
||||
#[rustc_const_unstable(feature = "float_next_up_down", issue = "91399")]
|
||||
pub const fn next_down(self) -> Self {
|
||||
// We must use strictly integer arithmetic to prevent denormals from
|
||||
// flushing to zero after an arithmetic operation on some platforms.
|
||||
// Some targets violate Rust's assumption of IEEE semantics, e.g. by flushing
|
||||
// denormals to zero. This is in general unsound and unsupported, but here
|
||||
// we do our best to still produce the correct result on such targets.
|
||||
let bits = self.to_bits();
|
||||
if self.is_nan() || bits == Self::NEG_INFINITY.to_bits() {
|
||||
return self;
|
||||
|
|
Loading…
Reference in a new issue