OpenersNotesSection(Spacer1)Details

If the data on the link corresponds to a real number, WSGetInteger32() will round it to an integer.

If the data on the link corresponds to an integer too large to store in a C int on your computer system, then WSGetInteger32() will fail, and return 0.

You can get arbitrary-precision integers by first using (RefLink[IntegerDigits, paclet:ref/IntegerDigits]) to generate lists of digits, then calling (NonWLLink[WSGetInteger32List(), paclet:ref/c/WSGetInteger32List]).

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

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

WSGetInteger32() is declared in the WSTP header file (RefLink[wstp.h, paclet:ref/file/wstp.h]).

OpenersPrimaryExamplesSection(Spacer1)Examples  (1)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

#include "wstp.h"

/* read a 32-bit integer from a link */

void f(WSLINK lp)
{
	int data;

	if(! WSGetInteger32(lp, &data))
		{ /* unable to read an integer from lp */ }

	/* use the integer */
}

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

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Manipulating Expressions in External Programs, paclet:tutorial/ManipulatingExpressionsInExternalPrograms])}, {▪(RefLinkPlain[Portability of WSTP Programs, paclet:tutorial/PortabilityOfWSTPPrograms])}, {▪(RefLinkPlain[WSTP C API Developer Guide (Mac OS X), paclet:tutorial/WSTPDeveloperGuide-MacintoshOverview])}, {▪(RefLinkPlain[WSTP C API Developer Guide (Unix and Linux), paclet:tutorial/WSTPDeveloperGuide-UnixOverview])}, {▪(RefLinkPlain[WSTP C API Developer Guide (Windows), paclet:tutorial/WSTPDeveloperGuide-WindowsOverview])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Alphabetical Listing of WSTP C Functions, paclet:guide/AlphabeticalListingOfWSTPCFunctions])}, {▪(RefLinkPlain[C/C++ Language Interface, paclet:guide/CLanguageInterface])}, {▪(RefLinkPlain[WSTP API, paclet:guide/WSTPAPI])}, {▪(RefLinkPlain[WSTP C Functions for Exchanging Integers, paclet:guide/WSTPCFunctionsForExchangingIntegers])}})}})