int MLGetInteger16(MLINK link, short *i)
gets a 16-bit integer from the MathLink connection specified by link and stores it as a C short in i.


  • If the data on the link corresponds to a real number, MLGetInteger16() 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 MLGetInteger16() will fail, and return 0.
  • You can get arbitrary-precision integers by first using IntegerDigits to generate lists of digits, then calling MLGetInteger16List().
  • MLGetInteger16() returns a nonzero value if the function succeeds.
  • Use MLError() to retrieve the error code if MLGetInteger16() fails.
  • MLGetInteger16() is declared in the MathLink header file mathlink.h.

ExamplesExamplesopen allclose all

Basic Examples (1)Basic Examples (1)

#include "mathlink.h"

/* read a short integer from a link */

void f(MLINK lp)
    short s;

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

    /* use the short integer */
New to Mathematica? Find your learning path »
Have a question? Ask support »