diff --git a/vala/long_double/float128type.h b/vala/long_double/float128type.h new file mode 100644 index 0000000..b230774 --- /dev/null +++ b/vala/long_double/float128type.h @@ -0,0 +1 @@ +typedef long double double128; diff --git a/vala/long_double/float128type.vapi b/vala/long_double/float128type.vapi new file mode 100644 index 0000000..685977d --- /dev/null +++ b/vala/long_double/float128type.vapi @@ -0,0 +1,3 @@ +[CCode (cname = "double128", has_type_id = false, cheader_filename = "float128type.h")] +public struct Double128 : double { +} diff --git a/vala/long_double/run.sh b/vala/long_double/run.sh new file mode 100755 index 0000000..78478e5 --- /dev/null +++ b/vala/long_double/run.sh @@ -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 diff --git a/vala/long_double/test128float.vala b/vala/long_double/test128float.vala new file mode 100644 index 0000000..f2107fa --- /dev/null +++ b/vala/long_double/test128float.vala @@ -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); +}