Double128 example added.
This commit is contained in:
parent
4e1c4111b2
commit
a1c7b35435
|
@ -0,0 +1 @@
|
|||
typedef long double double128;
|
|
@ -0,0 +1,3 @@
|
|||
[CCode (cname = "double128", has_type_id = false, cheader_filename = "float128type.h")]
|
||||
public struct Double128 : double {
|
||||
}
|
|
@ -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
|
|
@ -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);
|
||||
}
|
Loading…
Reference in New Issue