@@ -367,16 +367,15 @@ same trait object.
367367 * ** [ NOTE: currently this will cause Undefined Behavior if the rounded
368368 value cannot be represented by the target integer type] [ float-int ] ** .
369369 This includes Inf and NaN. This is a bug and will be fixed.
370- * Casting from an integer to float will produce the floating point
371- representation of the integer, rounded if necessary (rounding strategy
372- unspecified)
370+ * Casting from an integer to float will produce the closest possible float \*
371+ * if necessary, rounding is according to ` roundTiesToEven ` mode \*\*\*
372+ * on overflow, infinity (of the same sign as the input) is produced
373+ * note: with the current set of numeric types, overflow can only happen
374+ on ` u128 as f32 ` for values greater or equal to ` f32::MAX + (0.5 ULP) `
373375 * Casting from an f32 to an f64 is perfect and lossless
374- * Casting from an f64 to an f32 will produce the closest possible value
375- (rounding strategy unspecified)
376- * ** [ NOTE: currently this will cause Undefined Behavior if the value
377- is finite but larger or smaller than the largest or smallest finite
378- value representable by f32] [ float-float ] ** . This is a bug and will
379- be fixed.
376+ * Casting from an f64 to an f32 will produce the closest possible f32 \*\*
377+ * if necessary, rounding is according to ` roundTiesToEven ` mode \*\*\*
378+ * on overflow, infinity (of the same sign as the input) is produced
380379* Enum cast
381380 * Casts an enum to its discriminant, then uses a numeric cast if needed.
382381* Primitive to integer cast
@@ -385,8 +384,19 @@ same trait object.
385384* ` u8 ` to ` char ` cast
386385 * Casts to the ` char ` with the corresponding code point.
387386
387+ \* if integer-to-float casts with this rounding mode and overflow behavior are
388+ not supported natively by the hardware, these casts will likely be slower than
389+ expected.
390+
391+ \*\* if f64-to-f32 casts with this rounding mode and overflow behavior are not
392+ supported natively by the hardware, these casts will likely be slower than
393+ expected.
394+
395+ \*\*\* as defined in IEEE 754-2008 § ; 4.3.1: pick the nearest floating point
396+ number, preferring the one with an even least significant digit if exactly
397+ halfway between two floating point numbers.
398+
388399[ float-int ] : https://github.com/rust-lang/rust/issues/10184
389- [ float-float ] : https://github.com/rust-lang/rust/issues/15536
390400
391401## Assignment expressions
392402
0 commit comments