Matlab / Octave integer representation

For proper integer representation in Matlab / Octave use explicit type to avoid Matlab unwanted casting to “double” for integers.

x = int64(2^63);

Operations involving an explicitly-typed variable will retain that type, assuming implicit casting due to other variables or operations doesn’t occur. Precise string representation of “x” can be done using int2str(), sprintf(), or string():

xc = int2str(x);

xf = sprintf('%d', x);

xs = string(x);

sprintf() gives more control over the string output format, while string() or int2str() are more concise.