@@ -83,15 +83,22 @@ extern "platform-intrinsic" {
83
83
/// Otherwise, truncates or extends the value, maintaining the sign for signed integers.
84
84
///
85
85
/// # Safety
86
- /// Casting floats to integers truncates, but the truncated value must fit in the target type.
86
+ /// Casting from integer types is always safe.
87
+ /// Casting between two float types is also always safe.
88
+ ///
89
+ /// Casting floats to integers truncates, following the same rules as `to_int_unchecked`.
90
+ /// Specifically, each element must:
91
+ /// * Not be `NaN`
92
+ /// * Not be infinite
93
+ /// * Be representable in the return type, after truncating off its fractional part
87
94
pub fn simd_cast < T , U > ( x : T ) -> U ;
88
95
89
96
/// Numerically cast a vector, elementwise.
90
97
///
91
98
/// `T` and `U` be a vectors of integer or floating point primitive types, and must have the
92
99
/// same length.
93
100
///
94
- /// Like `simd_cast`, but saturates float-to-integer conversions.
101
+ /// Like `simd_cast`, but saturates float-to-integer conversions (NaN becomes 0) .
95
102
/// This matches regular `as` and is always safe.
96
103
///
97
104
/// When casting floats to integers, the result is truncated.
@@ -337,6 +344,10 @@ extern "platform-intrinsic" {
337
344
/// For example, `[!0, 0, !0, !0]` packs to `0b1101` on little endian and `0b1011` on big
338
345
/// endian.
339
346
///
347
+ /// To consider a larger example, `[!0, 0, 0, 0, 0, 0, 0, 0, !0, !0, 0, 0, 0, 0, !0, 0]` packs
348
+ /// to `[0b00000001, 0b01000011]` or `0b0100001100000001` on little endian, and `[0b10000000,
349
+ /// 0b11000010]` or `0b1000000011000010` on big endian.
350
+ ///
340
351
/// # Safety
341
352
/// `x` must contain only `0` and `!0`.
342
353
pub fn simd_bitmask < T , U > ( x : T ) -> U ;
0 commit comments