Stream: t-lang/wg-unsafe-code-guidelines

Topic: transmute::


Tony Arcieri (Apr 01 2019 at 00:23, on Zulip):

I am almost afraid to ask, but...

Tony Arcieri (Apr 01 2019 at 00:24, on Zulip):

f32::from_bits is cool

Tony Arcieri (Apr 01 2019 at 00:24, on Zulip):

what's the deal with the other direction?

Tony Arcieri (Apr 01 2019 at 00:24, on Zulip):

these sorts of f32 <-> u32 hacks seem super useful in making approximations of all sorts of arithmetic operations

Tony Arcieri (Apr 01 2019 at 00:26, on Zulip):

see the "quake invsqrt" or something like https://bits.stephan-brumme.com/squareRoot.html

Tony Arcieri (Apr 01 2019 at 00:26, on Zulip):

or https://ieeexplore.ieee.org/document/6375931

Tony Arcieri (Apr 01 2019 at 00:27, on Zulip):

but the core idea of all of these is f32 -> u32 -> [ bit twiddling ] -> u32 -> f32

Tony Arcieri (Apr 01 2019 at 00:27, on Zulip):

f32::from_bits is useful for the output

kennytm (Apr 01 2019 at 06:04, on Zulip):

What's wrong with f32::to_bits?

Tony Arcieri (Apr 01 2019 at 17:16, on Zulip):

whoa! it exists! awesome, thanks

Tony Arcieri (Apr 01 2019 at 17:16, on Zulip):

somehow I overlooked it

Last update: Nov 19 2019 at 18:50UTC