Why am I unable to correctly display 64-bit integers in MATLAB?
I'm having trouble using 64-bit integer variable types in MEX functions. It seems that even though the compiler (Microsoft Visual C++) accepts __int54 as a type definition, the variable is still only 32 bits.
The following function demonstrates this example:
#include <string.h> #include <stdlib.h> #include <stdio.h> #include "mex.h" #include "matrix.h" typedef __int32 long32; typedef __int64 long64; void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { long32 x_32; long64 x_64; x_32 = (long32)2147483648; // 2^31 x_64 = (long64)2147483648; mexPrintf("x_32 = %d, x_64 = %d\n",x_32,x_64); }
When run, this returns:
x_32 = -2147483648 x_64 = -2147483648
Best Answer