WSGetInteger16 (C Function)

int WSGetInteger16(WSLINK link,short *i)

gets a 16-bit integer from the WSTP connection specified by link and stores it as a C short in i.


  • If the data on the link corresponds to a real number, WSGetInteger16() will round it to an integer.
  • If the data on the link corresponds to an integer too large to store in a C short on your computer system, then WSGetInteger16() will fail, and return 0.
  • You can get arbitrary-precision integers by first using IntegerDigits to generate lists of digits, and then calling WSGetInteger16List().
  • WSGetInteger16() returns a nonzero value if the function succeeds.
  • Use WSError() to retrieve the error code if WSGetInteger16() fails.
  • WSGetInteger16() is declared in the WSTP header file wstp.h.


Basic Examples  (1)

#include "wstp.h"

/* read a short integer from a link */

void f(WSLINK lp)
    short s;

    if(! WSGetInteger16(lp, &s))
        { /* unable to read the integer from lp */ }

    /* use the short integer */