mirror of
https://github.com/kanjitalk755/macemu.git
synced 2024-11-19 09:30:56 +00:00
Use extra precision (e.g. long double) for fma operations though this
inhibits some underflow conditions.
This commit is contained in:
parent
98dea63921
commit
0123552ddc
@ -84,6 +84,31 @@ enum {
|
||||
#endif
|
||||
|
||||
// Floating-Point Multiply Add/Subtract functions
|
||||
#if (SIZEOF_LONG_DOUBLE > SIZEOF_DOUBLE) && (SIZEOF_DOUBLE > SIZEOF_FLOAT)
|
||||
// FIXME: this is wrong for underflow conditions
|
||||
#ifndef mathlib_fmadd
|
||||
static inline double mathlib_fmadd(double x, double y, double z)
|
||||
{
|
||||
return ((long double)x * (long double)y) + z;
|
||||
}
|
||||
static inline float mathlib_fmadd(float x, float y, float z)
|
||||
{
|
||||
return ((double)x * (double)y) + z;
|
||||
}
|
||||
#define mathlib_fmadd(x, y, z) (mathlib_fmadd)(x, y, z)
|
||||
#endif
|
||||
#ifndef mathlib_fmsub
|
||||
static inline double mathlib_fmsub(double x, double y, double z)
|
||||
{
|
||||
return ((long double)x * (long double)y) - z;
|
||||
}
|
||||
static inline float mathlib_fmsub(float x, float y, float z)
|
||||
{
|
||||
return ((double)x * (double)y) - z;
|
||||
}
|
||||
#define mathlib_fmsub(x, y, z) (mathlib_fmsub)(x, y, z)
|
||||
#endif
|
||||
#endif
|
||||
#ifndef mathlib_fmadd
|
||||
#define mathlib_fmadd(x, y, z) (((x) * (y)) + (z))
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user