|
79 | 79 |
|
80 | 80 | #endif // defined(__cplusplus) |
81 | 81 |
|
82 | | -// ----------------------------------------------------------------------------- |
83 | | -// Standard library functions. |
84 | | -// ----------------------------------------------------------------------------- |
85 | | - |
86 | | -#if defined(__cplusplus) |
87 | | - |
88 | | -inline float floatbits(vkl_uint32 bits) |
89 | | -{ |
90 | | - VKL_INTEROP_STATIC_ASSERT(sizeof(float) == sizeof(vkl_uint32), |
91 | | - "Float is not 4 Bytes."); |
92 | | - float fval = 0.f; |
93 | | - reinterpret_cast<char *>(&fval)[0] = reinterpret_cast<const char *>(&bits)[0]; |
94 | | - reinterpret_cast<char *>(&fval)[1] = reinterpret_cast<const char *>(&bits)[1]; |
95 | | - reinterpret_cast<char *>(&fval)[2] = reinterpret_cast<const char *>(&bits)[2]; |
96 | | - reinterpret_cast<char *>(&fval)[3] = reinterpret_cast<const char *>(&bits)[3]; |
97 | | - return fval; |
98 | | -} |
99 | | - |
100 | | -inline vkl_uint32 intbits(float value) |
101 | | -{ |
102 | | - VKL_INTEROP_STATIC_ASSERT(sizeof(float) == sizeof(vkl_uint32), |
103 | | - "Float is not 4 Bytes."); |
104 | | - vkl_uint32 ival = 0; |
105 | | - reinterpret_cast<char *>(&ival)[0] = |
106 | | - reinterpret_cast<const char *>(&value)[0]; |
107 | | - reinterpret_cast<char *>(&ival)[1] = |
108 | | - reinterpret_cast<const char *>(&value)[1]; |
109 | | - reinterpret_cast<char *>(&ival)[2] = |
110 | | - reinterpret_cast<const char *>(&value)[2]; |
111 | | - reinterpret_cast<char *>(&ival)[3] = |
112 | | - reinterpret_cast<const char *>(&value)[3]; |
113 | | - return ival; |
114 | | -} |
115 | | - |
116 | | -#endif |
117 | | - |
118 | 82 | // ----------------------------------------------------------------------------- |
119 | 83 | // Helpers for univary definitions. |
120 | 84 | // ----------------------------------------------------------------------------- |
|
0 commit comments