mirror of
https://github.com/frida/tinycc
synced 2024-11-30 19:43:07 +03:00
add tests for float conversions to u64
Note: I removed the test that used sin() function because it makes no sense to use that there and besides I could not get the test to work because sin requires -lm linked but for some reason make does not compile with -lm and I get errors like undefined symbol sin. Coerce function should do the same thing for the purposes of that test.
This commit is contained in:
parent
618ba55a81
commit
a5e714abec
@ -14,6 +14,12 @@ test()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double coerce(double x)
|
||||||
|
{
|
||||||
|
x++;
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
// variables
|
// variables
|
||||||
@ -55,7 +61,31 @@ int main()
|
|||||||
// type coercion
|
// type coercion
|
||||||
a = 2;
|
a = 2;
|
||||||
printf("%f\n", a);
|
printf("%f\n", a);
|
||||||
printf("%f\n", sin(2));
|
printf("%f\n", coerce(2));
|
||||||
|
|
||||||
|
//type conversion to unsigned long int
|
||||||
|
float f = 3421.439;
|
||||||
|
double d = 7855.332231;
|
||||||
|
long double ld = 2469.346786989643234;
|
||||||
|
|
||||||
|
unsigned long int i;
|
||||||
|
i = f;
|
||||||
|
printf("%lu\n", i);
|
||||||
|
i = d;
|
||||||
|
printf("%lu\n", i);
|
||||||
|
i = ld;
|
||||||
|
printf("%lu\n", i);
|
||||||
|
|
||||||
|
f = -3421.439;
|
||||||
|
d = -7855.332231;
|
||||||
|
ld = -2469.346786989643234;
|
||||||
|
i = f;
|
||||||
|
printf("%lu\n", i);
|
||||||
|
i = d;
|
||||||
|
printf("%lu\n", i);
|
||||||
|
i = ld;
|
||||||
|
printf("%lu\n", i);
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -13,4 +13,10 @@
|
|||||||
12.340000
|
12.340000
|
||||||
-12.340000
|
-12.340000
|
||||||
2.000000
|
2.000000
|
||||||
0.909297
|
3.000000
|
||||||
|
3421
|
||||||
|
7855
|
||||||
|
2469
|
||||||
|
18446744073709548195
|
||||||
|
18446744073709543761
|
||||||
|
18446744073709549147
|
||||||
|
Loading…
Reference in New Issue
Block a user