* @brief Unsigned integer bit-interpreted as a signed integer. * * @param v The value to bitcast. * * @return The converted value. */
| 426 | * @return The converted value. |
| 427 | */ |
| 428 | static inline int uint_as_int(unsigned int v) |
| 429 | { |
| 430 | // Future: Can use std:bit_cast with C++20 |
| 431 | int sv; |
| 432 | std::memcpy(&sv, &v, sizeof(unsigned int)); |
| 433 | return sv; |
| 434 | } |
| 435 | |
| 436 | /** |
| 437 | * @brief Fast approximation of 1.0 / sqrt(val). |