#include "testconfig.h"
#ifdef HAVE_SIGNIFICAND
#define TEST_FUNC_F_F __MATH_PRECNAME(wrap_significand)
static REAL TEST_FUNC_F_F(REAL x)
{
	return __MATH_PRECNAME(significand)(x);
}
#include "testdriver.h"



static test_f_f_data const significand_data[] = {
	{ __LINE__, QNAN_P, QNAN_P, 0 },
	{ __LINE__, QNAN_M, QNAN_P, 0 },
	{ __LINE__, SNAN_P, QNAN_P, 0 },
	{ __LINE__, SNAN_M, QNAN_P, 0 },
	{ __LINE__, INF_P, INF_P, FLAG_FAIL_SOFTFLOAT|FLAG_XFAIL },
	{ __LINE__, INF_M, INF_M, FLAG_FAIL_SOFTFLOAT|FLAG_XFAIL },
	{ __LINE__, ZERO_P, ZERO_P, 0 },
	{ __LINE__, ZERO_M, ZERO_M, FLAG_FAIL_ARANYM2 },
	{ __LINE__, SUBNORM_P, ZERO_P, FLAG_SUBNORM },
	{ __LINE__, SUBNORM_M, ZERO_M, FLAG_SUBNORM },
	{ __LINE__, MIN_P, HEXCONSTE(1.0, 0x3fff, 0x80000000L, 0x00000000L), 0 },
	{ __LINE__, MIN_M, HEXCONSTE(-1.0, 0xbfff, 0x80000000L, 0x00000000L), 0 },
	{ __LINE__, MAX_P, HEXCONSTE(1.9999999999999999998916e+00, 0x3fff, 0xffffffffL, 0xffffffffL), 0 },
	{ __LINE__, MAX_M, HEXCONSTE(-1.9999999999999999998916e+00, 0xbfff, 0xffffffffL, 0xffffffffL), 0 },

	{ __LINE__, HEXCONSTE(4.0, 0x4001, 0x80000000L, 0x00000000L), HEXCONSTE(1.0, 0x3fff, 0x80000000L, 0x00000000L), NO_INEXACT_EXCEPTION },
	{ __LINE__, HEXCONSTE(6.0, 0x4001, 0xc0000000L, 0x00000000L), HEXCONSTE(1.5, 0x3fff, 0xc0000000L, 0x00000000L), NO_INEXACT_EXCEPTION },
	{ __LINE__, HEXCONSTE(8.0, 0x4002, 0x80000000L, 0x00000000L), HEXCONSTE(1.0, 0x3fff, 0x80000000L, 0x00000000L), NO_INEXACT_EXCEPTION },
	{ __LINE__, HEXCONSTE(0.4, 0x3ffd, 0xccccccccL, 0xcccccccdL), HEXCONSTE(1.6, 0x3fff, 0xccccccccL, 0xcccccccdL), NO_INEXACT_EXCEPTION },
	{ __LINE__, HEXCONSTE(0.6, 0x3ffe, 0x99999999L, 0x9999999aL), HEXCONSTE(1.2, 0x3fff, 0x99999999L, 0x9999999aL), NO_INEXACT_EXCEPTION },
	{ __LINE__, HEXCONSTE(0.8, 0x3ffe, 0xccccccccL, 0xcccccccdL), HEXCONSTE(1.6, 0x3fff, 0xccccccccL, 0xcccccccdL), NO_INEXACT_EXCEPTION },
	{ __LINE__, HEXCONSTE(0.0004, 0x3ff3, 0xd1b71758L, 0xe219652cL), HEXCONSTE(1.6384, 0x3fff, 0xd1b71758L, 0xe219652cL), NO_INEXACT_EXCEPTION },
	{ __LINE__, HEXCONSTE(0.0006, 0x3ff4, 0x9d495182L, 0xa9930be1L), HEXCONSTE(1.2288, 0x3fff, 0x9d495182L, 0xa9930be1L), NO_INEXACT_EXCEPTION },
	{ __LINE__, HEXCONSTE(0.0008, 0x3ff4, 0xd1b71758L, 0xe219652cL), HEXCONSTE(1.6384, 0x3fff, 0xd1b71758L, 0xe219652cL), NO_INEXACT_EXCEPTION },
	{ __LINE__, HEXCONSTE(-4.0, 0xc001, 0x80000000L, 0x00000000L), HEXCONSTE(-1.0, 0xbfff, 0x80000000L, 0x00000000L), NO_INEXACT_EXCEPTION },
	{ __LINE__, HEXCONSTE(-6.0, 0xc001, 0xc0000000L, 0x00000000L), HEXCONSTE(-1.5, 0xbfff, 0xc0000000L, 0x00000000L), NO_INEXACT_EXCEPTION },
	{ __LINE__, HEXCONSTE(-8.0, 0xc002, 0x80000000L, 0x00000000L), HEXCONSTE(-1.0, 0xbfff, 0x80000000L, 0x00000000L), NO_INEXACT_EXCEPTION },
	{ __LINE__, HEXCONSTE(-0.4, 0xbffd, 0xccccccccL, 0xcccccccdL), HEXCONSTE(-1.6, 0xbfff, 0xccccccccL, 0xcccccccdL), NO_INEXACT_EXCEPTION },
	{ __LINE__, HEXCONSTE(-0.6, 0xbffe, 0x99999999L, 0x9999999aL), HEXCONSTE(-1.2, 0xbfff, 0x99999999L, 0x9999999aL), NO_INEXACT_EXCEPTION },
	{ __LINE__, HEXCONSTE(-0.8, 0xbffe, 0xccccccccL, 0xcccccccdL), HEXCONSTE(-1.6, 0xbfff, 0xccccccccL, 0xcccccccdL), NO_INEXACT_EXCEPTION },
	{ __LINE__, HEXCONSTE(-0.0004, 0xbff3, 0xd1b71758L, 0xe219652cL), HEXCONSTE(-1.6384, 0xbfff, 0xd1b71758L, 0xe219652cL), NO_INEXACT_EXCEPTION },
	{ __LINE__, HEXCONSTE(-0.0006, 0xbff4, 0x9d495182L, 0xa9930be1L), HEXCONSTE(-1.2288, 0xbfff, 0x9d495182L, 0xa9930be1L), NO_INEXACT_EXCEPTION },
	{ __LINE__, HEXCONSTE(-0.0008, 0xbff4, 0xd1b71758L, 0xe219652cL), HEXCONSTE(-1.6384, 0xbfff, 0xd1b71758L, 0xe219652cL), NO_INEXACT_EXCEPTION },
};


int main(int argc, char **argv)
{
	int status;
	
	status = 0;
	
	test_init(argc, argv);
	
	status |= test_table_f_f(significand_data, ARRAY_SIZE(significand_data), __FILE__);
	
	return status ? EXIT_FAILURE : EXIT_SUCCESS;
}

#else

int main(void)
{
	return 77;
}

#endif
