• source navigation  • diff markup  • identifier search  • freetext search  • 

Sources/ucode/tests/custom/17_lib_ffi/34_complex_repr

  1 A complex number is represented as a CT_ARRAY of two reals, so the width of the
  2 value decides which pair of conversions converts it back. Only the three widths
  3 libffi provides complex types for are representable; any other width must not
  4 fall through to the narrowest one, whose conversions are themselves complex and
  5 would re-enter the representation with the same width until the stack is
  6 exhausted, so it is reported instead.
  7 
  8 Represent the complex types of the widths libffi provides.
  9 
 10 -- Testcase --
 11 {%
 12     import * as ffi from 'ffi';
 13 
 14     // Only the three widths libffi provides complex types for can be converted
 15     // back. Any other width must not fall through to the narrowest one, whose
 16     // conversions are themselves complex and would re-enter the
 17     // representation with the same width until the stack is exhausted.
 18     print("float:  ", ffi.ctype('float complex', 1.0, 2.0).tostring(), "\n");
 19     print("double: ", ffi.ctype('double complex', 1.0, 2.0).tostring(), "\n");
 20     print("long:   ", ffi.ctype('long double complex', 1.0, 2.0).tostring(), "\n");
 21 %}
 22 -- End --
 23 
 24 -- Expect stdout --
 25 float:  complex float: 1+2i
 26 double: complex: 1+2i
 27 long:   complex: 1+2i
 28 -- End --

This page was automatically generated by LXR 0.3.1.  •  OpenWrt