WSGetReal64 (C Function)

int WSGetReal64(WSLINK link,double *x)

gets a double-precision floating-point number from the WSTP connection link and stores it in x.

Details

  • If the data on the link corresponds to a C int, WSGetReal64() will coerce it to a double before storing it in x.
  • If the data on the link corresponds to a number outside the range that can be stored in a C double on your computer system, then WSGetReal64() will fail, and return 0.
  • Arbitrary-precision real numbers are transmitted between WSTP programs as the number sequence generated by RealDigits, typically as an integer array or as a C string of decimal characters. This sequence can be read using WSGetInteger32List() or WSGetString().
  • WSGetReal64() returns 0 in the event of an error, and a nonzero value if the function succeeds.
  • Use WSError() to retrieve the error code if WSGetReal64() fails.
  • WSGetReal64() is declared in the WSTP header file wstp.h.

Examples

Basic Examples  (1)

#include "wstp.h"

/* read a double-precision floating-point number from a link */

void f(WSLINK lp)
{
    double r;

    if(! WSGetReal64(lp, &r))
        { /* unable to read the floating-point number from lp */ }

    /* ... */
}