#include "ffitest.h"
#include "float.h"
+#include <math.h>
+
typedef union
{
double d;
/* These are not always the same!! Check for a reasonable delta */
- CHECK(result[0].d - dblit(f) < DBL_EPSILON);
+ CHECK(fabs(result[0].d - dblit(f)) < DBL_EPSILON);
/* Check the canary. */
for (i = 0; i < sizeof (double); ++i)
#include "ffitest.h"
#include "float.h"
+#include <math.h>
+
static long double ldblit(float f)
{
return (long double) (((long double) f)/ (long double) 3.0);
#endif
/* These are not always the same!! Check for a reasonable delta */
- if (ld - ldblit(f) < LDBL_EPSILON)
+ if (fabsl(ld - ldblit(f)) < LDBL_EPSILON)
puts("long double return value tests ok!");
else
CHECK(0);
#include "ffitest.h"
#include "float.h"
+#include <math.h>
+
static double floating_1(float a, double b, long double c)
{
return (double) a + b + (double) c;
ffi_call(&cif, FFI_FN(floating_1), &rd, values);
- CHECK(rd - floating_1(f, d, ld) < DBL_EPSILON);
+ CHECK(fabs(rd - floating_1(f, d, ld)) < DBL_EPSILON);
args[0] = &ffi_type_longdouble;
values[0] = &ld;
ffi_call(&cif, FFI_FN(floating_2), &rd, values);
- CHECK(rd - floating_2(ld, d, f) < DBL_EPSILON);
+ CHECK(fabs(rd - floating_2(ld, d, f)) < DBL_EPSILON);
exit (0);
}