Merge pull request #6873 from lioncash/bit

Interpreter_FPUtils: Use Common::BitCast where applicable
This commit is contained in:
Tilka 2018-05-17 02:12:07 +01:00 committed by GitHub
commit 82d9dea245
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 15 deletions

View File

@ -5,9 +5,9 @@
#pragma once
#include <cmath>
#include <cstring>
#include <limits>
#include "Common/BitUtils.h"
#include "Common/CPUDetect.h"
#include "Common/CommonTypes.h"
#include "Common/FloatUtils.h"
@ -73,28 +73,18 @@ inline double ForceDouble(double d)
inline double Force25Bit(double d)
{
u64 integral;
std::memcpy(&integral, &d, sizeof(u64));
u64 integral = Common::BitCast<u64>(d);
integral = (integral & 0xFFFFFFFFF8000000ULL) + (integral & 0x8000000);
double result;
std::memcpy(&result, &integral, sizeof(double));
return result;
return Common::BitCast<double>(integral);
}
inline double MakeQuiet(double d)
{
u64 integral;
std::memcpy(&integral, &d, sizeof(u64));
const u64 integral = Common::BitCast<u64>(d) | Common::DOUBLE_QBIT;
integral |= Common::DOUBLE_QBIT;
double result;
std::memcpy(&result, &integral, sizeof(double));
return result;
return Common::BitCast<double>(integral);
}
// these functions allow globally modify operations behaviour