Skip to content

Commit bb555b8

Browse files
Fix comments for float classify
1 parent 8358179 commit bb555b8

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

library/core/src/num/f32.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ impl f32 {
594594
// However, std can't simply compare to zero to check for zero, either,
595595
// as correctness requires avoiding equality tests that may be Subnormal == -0.0
596596
// because it may be wrong under "denormals are zero" and "flush to zero" modes.
597-
// Most of std's targets don't use those, but they are used for thumbv7neon".
597+
// Most of std's targets don't use those, but they are used for thumbv7neon.
598598
// So, this does use bitpattern matching for the rest.
599599

600600
// SAFETY: f32 to u32 is fine. Usually.
@@ -609,6 +609,12 @@ impl f32 {
609609
// FIXME(jubilee): This probably could at least answer things correctly for Infinity,
610610
// like the f64 version does, but I need to run more checks on how things go on x86.
611611
// I fear losing mantissa data that would have answered that differently.
612+
//
613+
// # Safety
614+
// This requires making sure you call this function for values it answers correctly on,
615+
// otherwise it returns a wrong answer. This is not important for memory safety per se,
616+
// but getting floats correct is important for not accidentally leaking const eval
617+
// runtime-deviating logic which may or may not be acceptable.
612618
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
613619
const unsafe fn partial_classify(self) -> FpCategory {
614620
const EXP_MASK: u32 = 0x7f800000;
@@ -992,7 +998,7 @@ impl f32 {
992998
// ...sorta.
993999
//
9941000
// It turns out that at runtime, it is possible for a floating point number
995-
// to be subject to a floating point mode that alters nonzero subnormal numbers
1001+
// to be subject to floating point modes that alter nonzero subnormal numbers
9961002
// to zero on reads and writes, aka "denormals are zero" and "flush to zero".
9971003
// This is not a problem usually, but at least one tier2 platform for Rust
9981004
// actually exhibits this behavior by default: thumbv7neon

library/core/src/num/f64.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ impl f64 {
593593
// However, std can't simply compare to zero to check for zero, either,
594594
// as correctness requires avoiding equality tests that may be Subnormal == -0.0
595595
// because it may be wrong under "denormals are zero" and "flush to zero" modes.
596-
// Most of std's targets don't use those, but they are used for thumbv7neon".
596+
// Most of std's targets don't use those, but they are used for thumbv7neon.
597597
// So, this does use bitpattern matching for the rest.
598598

599599
// SAFETY: f64 to u64 is fine. Usually.
@@ -991,10 +991,10 @@ impl f64 {
991991
// ...sorta.
992992
//
993993
// It turns out that at runtime, it is possible for a floating point number
994-
// to be subject to floating point modes that alters nonzero subnormal numbers
994+
// to be subject to floating point modes that alter nonzero subnormal numbers
995995
// to zero on reads and writes, aka "denormals are zero" and "flush to zero".
996996
// This is not a problem usually, but at least one tier2 platform for Rust
997-
// actually exhibits an FTZ behavior kby default: thumbv7neon
997+
// actually exhibits an FTZ behavior by default: thumbv7neon
998998
// aka "the Neon FPU in AArch32 state"
999999
//
10001000
// Even with this, not all instructions exhibit the FTZ behaviors on thumbv7neon,

0 commit comments

Comments
 (0)