Passing Floats
     Prolog:  +float
     C:       double x;
     

The C double-precision float is converted to a Prolog float, which is passed to the Prolog call. If the C double contains garbage, Prolog will receive that garbage as a double-precision floating-point number. Many C compilers will allow the parameter declaration to be float instead of double because they always convert single-precision floating-point arguments to double-precision. However, C compilers conforming to the new ANSI standard will not do this, so it is recommended that double be used.

     Prolog:  +single
     ANSI C:  float x;
     

The C single-precision float is converted to a Prolog float, which is passed to the Prolog call. If the C float contains garbage, Prolog will receive that garbage as a single-precision floating-point number.

Normally, this type of argument is not used; however, C compilers conforming to the new ANSI standard can pass single precision floats to Prolog without first converting them to double. It is not recommended that floats be passed as single until you have verified that your C compiler behaves as desired.

     Prolog:  +double
     C:       double x;
     

The C double-precision float is converted to a Prolog float, which is passed to the Prolog call. If the C float contains garbage, Prolog will receive that garbage as a double-precision floating-point number.

     Prolog:  -float
     C:       float *x;
     

A pointer to a C float is passed to the foreign interface. When Prolog returns a solution, a Prolog floating-point number is expected in the corresponding argument of the call. The foreign interface converts that number into a C float and writes it at the location supplied. The previous contents of the location are destroyed. If the Prolog call does not return a floating-point number in the appropriate position, a type error is raised and the contents of the location is unchanged.

     Prolog:  -single
     C:       float *x;
     

A pointer to a C float is passed to the foreign interface. When Prolog returns a solution, a Prolog floating-point number is expected in the corresponding argument of the call. The foreign interface converts that number into a C float and writes it at the location supplied. The previous contents of the location are destroyed. If the Prolog call does not return a floating-point number in the appropriate position, a type error is raised and the contents of the location is unchanged.

When the foreign language calling Prolog is C, this type of argument is not normally used; however, C compilers conforming to the new ANSI standard can return single precision floats from Prolog without first converting them to double. It is not recommended that floats be passed as single until you have verified that your C compiler behaves as desired.

     Prolog:  -double
     C:       double *x;
     

A pointer to a C double is passed to the foreign interface. When Prolog returns a solution, a Prolog floating-point number is expected in the corresponding argument of the call. The foreign interface converts that number into a C double and writes it at the location supplied. The previous contents of the location will be destroyed. If the Prolog call does not return a floating-point number in the appropriate position, a type error is signaled and the contents of the location is unchanged.

It is assumed that the interface will overwrite this float with Prolog's result. When Prolog returns, its floating-point number is converted to double-precision and written onto the space for the foreign double. The previous contents of the C double will be lost. If the Prolog call does not return a floating-point number, a type error is raised and the result is unchanged.