Host introspection: Difference between revisions

Content added Content deleted
Line 348: Line 348:
32 bits
32 bits
</pre>
</pre>



=={{header|MATLAB}} / {{header|Octave}}==

The concept of "word size" is not meaningful in Matlab and Octave, uint64 is also available on 32bit-platforms, and there are no pointers. Endianity can be tested with the function below:

<lang MATLAB> function [endian]=endian()
fid=tmpfile();
fwrite(fid,1:8,'uint8');

fseek(fid,0,'bof');
t=fread(fid,8,'int8');
i8=sprintf('%02X',t);

fseek(fid,0,'bof');
t=fread(fid,4,'int16');
i16=sprintf('%04X',t);

fclose(fid);

if strcmp(i8,i16) endian='big';
else endian='little';
end;
</lang>

Output:
<pre> octave:128> computer
x86_64-unknown-linux-gnu
octave:129> endian
endian = little</pre>