Double128 example added.

This commit is contained in:
Kolan Sh 2017-08-08 19:02:30 +03:00
parent 4e1c4111b2
commit a1c7b35435
4 changed files with 22 additions and 0 deletions

View File

@ -0,0 +1 @@
typedef long double double128;

View File

@ -0,0 +1,3 @@
[CCode (cname = "double128", has_type_id = false, cheader_filename = "float128type.h")]
public struct Double128 : double {
}

1
vala/long_double/run.sh Executable file
View File

@ -0,0 +1 @@
valac --pkg=float128type --vapidir=. -C test128float.vala && cc -I. `pkg-config --cflags glib-2.0` test128float.c `pkg-config --libs glib-2.0` && ./a.out

View File

@ -0,0 +1,17 @@
void main () {
stdout.printf ("sizeof (double) = %lu\n", sizeof(double));
stdout.printf ("sizeof (Double128) = %lu\n", sizeof(Double128));
Double128 d1 = 16.0;
stdout.printf ("Double128: 16 ^ 2 = %f\n", d1 * d1);
double d = 1e-15;
stdout.printf ("double: d = %e, ", d);
d += 1; d -= 1;
stdout.printf ("(+-1) d = %e\n", d);
Double128 ld = 1e-19;
stdout.printf ("Double128: ld = %e, ", ld);
ld += 1; ld -= 1;
stdout.printf ("(+-1) ld = %e\n", ld);
}