Skip to content

Commit 148483f

Browse files
committed
Remove from_f32(...) and note that the type can only be constructed through vendor intrinsics
1 parent 0601c45 commit 148483f

1 file changed

Lines changed: 1 addition & 14 deletions

File tree

text/3983-bf16.md

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -72,25 +72,12 @@ Alternatively, some other compiler magic could map the struct to LLVM's `bfloat`
7272
```rust
7373
impl bf16 {
7474
pub const fn from_bits(bits: u16) -> bf16;
75-
pub const fn from_f32(flt: f32) -> bf16;
7675
pub const fn to_bits(self) -> u16;
7776
}
7877
```
7978

80-
Where `from_f32` would allow instantiating a `bf16` and could look something like the following;
79+
Constructing a `bf16` can intially only be done through either `bf16::from_bits(...)` or vendor intrinsics.
8180

82-
```rust
83-
// in the `impl bf16 {` block
84-
pub fn from_f32(flt: f32) -> Self {
85-
let bits = flt.to_bits();
86-
if bits & 0x7FFF_FFFF > 0x7F80_0000 {
87-
return Self(((bits >> 16) as u16) | 0x0040);
88-
}
89-
let retained_lsb = (bits >> 16) & 1;
90-
let rounding_bias = 0x7FFF + retained_lsb;
91-
Self((bits.wrapping_add(rounding_bias) >> 16) as u16)
92-
}
93-
```
9481

9582
### Implemented Traits
9683
[implemented-traits]: #implemented-traits

0 commit comments

Comments
 (0)