Created
September 10, 2016 17:40
-
-
Save x4m/a5066149af47ddbe60b4c905318054c9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float pack_float_bits(const float v, const int r) | |
{ | |
union { | |
float f; | |
struct { unsigned value:31, sign:1; } vbits; | |
struct { unsigned value:29, realm:2, sign:1; } rbits; | |
} a; | |
a.f = v; | |
a.rbits.value = a.vbits.value >> 2; | |
a.rbits.realm = r; | |
return a.f; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment