* Test case execution for: long double __floattitf (__int128_t)
* Conversion from 128 bit integer to long double (IBM double-double).
*/
#include <stdint.h>
#include <stdio.h>
#include "floattitf_test.h"
* the long double, and the corresponding bit patterns of each double. */
typedef union {
long double ld;
double d[2];
unsigned long long ull[2];
} ldUnion;
long double __floattitf(__int128_t);
int main(int argc, char *argv[]) {
* compare computed and expected high and low portions of the
* IBM double-double. */
ldUnion expectedLongDouble;
ldUnion computedLongDouble;
__int128_t result128;
for (int i = 0; i < numTests; ++i) {
* and the 128 bit integer input to be converted. */
expectedLongDouble.d[0] = tests[i].hi;
expectedLongDouble.d[1] = tests[i].lo;
result128 = tests[i].input128;
* and check for errors between high and low portions. */
computedLongDouble.ld = __floattitf(result128);
if ((computedLongDouble.d[0] != expectedLongDouble.d[0]) ||
(computedLongDouble.d[1] != expectedLongDouble.d[1])) {
printf("Error on __floattitf( 0x%016llx 0x%016llx ):\n",
(long long)(tests[i].input128 >> 64),
(long long)tests[i].input128);
printf("\tExpected value - %La = ( %a, %a )\n", expectedLongDouble.ld,
expectedLongDouble.d[0], expectedLongDouble.d[1]);
printf("\tComputed value - %La = ( %a, %a )\n\n", computedLongDouble.ld,
computedLongDouble.d[0], computedLongDouble.d[1]);
return 1;
}
}
return 0;
}