1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
/* { dg-options "-O0 -mlong-double-128" } */
#include <stdio.h>
#include <stdlib.h>
void
check_ll (long double ld, long long ll)
{
if ((long long)ld != ll)
{
printf ("ld: %Lf expect: %lld result: %lld\n",
ld, ll, (long long)ld);
abort ();
}
}
void
check_ull (long double ld, unsigned long long ull)
{
if ((unsigned long long)ld != ull)
{
printf ("ld: %Lf expect: %llu result: %llu\n",
ld, ull, (unsigned long long)ld);
abort ();
}
}
int
main ()
{
const long long ll_max = (long long)((1ULL << 63) - 1);
const long long ll_min = -ll_max - 1;
check_ll (206.23253, 206LL);
check_ull (206.23253, 206ULL);
check_ll ((long double)ll_max, ll_max);
check_ull ((long double)ll_max, ll_max);
check_ll ((long double)ll_min, ll_min);
check_ll (0.0, 0);
check_ull (0.0, 0);
check_ll (-1.0, -1);
check_ll ((long double)0xffffffffffffffffULL, ll_max);
check_ull ((long double)0xffffffffffffffffULL, 0xffffffffffffffffULL);
return 0;
}
|