OpenersNotesSection(Spacer1)Details

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 (RefLink[IntegerDigits, paclet:ref/IntegerDigits]) to generate lists of digits, and then calling (NonWLLink[MLGetInteger16List(), paclet:ref/c/MLGetInteger16List]).

MLGetInteger16() returns a nonzero value if the function succeeds.

Use (NonWLLink[MLError(), paclet:ref/c/MLError]) to retrieve the error code if MLGetInteger16() fails.

MLGetInteger16() is declared in the MathLink header file (RefLink[mathlink.h, paclet:ref/file/mathlink.h]).

OpenersPrimaryExamplesSection(Spacer1)Examples  (1)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

#include "mathlink.h"

/* read a short integer from a link */

void f(MLINK lp)
{
	short s;

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

	/* use the short integer */
}

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(NonWLLink[MLGetInteger32(), paclet:ref/c/MLGetInteger32])  ▪  (NonWLLink[MLGetInteger64(), paclet:ref/c/MLGetInteger64])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Manipulating Expressions in External Programs, paclet:tutorial/ManipulatingExpressionsInExternalPrograms])}})}})