mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-17 02:50:29 +00:00
Core/Misc: Remove dependency on undefined behaviour (#2678)
Co-authored-by: Ujp8LfXBJ6wCPR <github@lillecarl.com> Co-authored-by: Ujp8LfXBJ6wCPR <github@lillecarl.com>
This commit is contained in:
@@ -18,29 +18,26 @@
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
#include <cmath>
|
||||
#include "string.h"
|
||||
|
||||
#define MAX_STACK_SIZE 64
|
||||
|
||||
// https://stackoverflow.com/a/4328396
|
||||
|
||||
static inline uint32 floatToRawIntBits(float f)
|
||||
{
|
||||
union
|
||||
{
|
||||
uint32 ival;
|
||||
float fval;
|
||||
} temp;
|
||||
temp.fval=f;
|
||||
return temp.ival;
|
||||
static_assert(sizeof(float) == sizeof(uint32), "Size of uint32 and float must be equal for this to work");
|
||||
uint32 ret;
|
||||
memcpy(&ret, &f, sizeof(float));
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline float intBitsToFloat(uint32 i)
|
||||
{
|
||||
union
|
||||
{
|
||||
uint32 ival;
|
||||
float fval;
|
||||
} temp;
|
||||
temp.ival=i;
|
||||
return temp.fval;
|
||||
static_assert(sizeof(float) == sizeof(uint32), "Size of uint32 and float must be equal for this to work");
|
||||
float ret;
|
||||
memcpy(&ret, &i, sizeof(uint32));
|
||||
return ret;
|
||||
}
|
||||
|
||||
struct AABound
|
||||
|
||||
Reference in New Issue
Block a user