@@ -367,16 +367,15 @@ same trait object.
367
367
* ** [ NOTE: currently this will cause Undefined Behavior if the rounded
368
368
value cannot be represented by the target integer type] [ float-int ] ** .
369
369
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) `
373
375
* 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
380
379
* Enum cast
381
380
* Casts an enum to its discriminant, then uses a numeric cast if needed.
382
381
* Primitive to integer cast
@@ -385,8 +384,19 @@ same trait object.
385
384
* ` u8 ` to ` char ` cast
386
385
* Casts to the ` char ` with the corresponding code point.
387
386
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
+
388
399
[ float-int ] : https://github.com/rust-lang/rust/issues/10184
389
- [ float-float ] : https://github.com/rust-lang/rust/issues/15536
390
400
391
401
## Assignment expressions
392
402
0 commit comments