Is there a function to tell if Matlab is using little-endian or big-endian on current computer?

21 visualizzazioni (ultimi 30 giorni)
Is there a function to tell if Matlab is using little-endian or big-endian on current computer?

Risposta accettata

Steven Lord
Steven Lord il 17 Dic 2024
See the third output from the computer function.
[str, maxsize, endianness] = computer
str = 'GLNXA64'
maxsize = 2.8147e+14
endianness = 'L'

Più risposte (1)

Matt J
Matt J il 17 Dic 2024
Modificato: Matt J il 17 Dic 2024
function endianType = checkEndian()
% Typecast uint16(1) to uint8 to examine the byte order
byteValue = typecast(uint16(1), 'uint8');
% Check the first byte to determine endianness
if byteValue(1) == 1
endianType = 'little-endian';
else
endianType = 'big-endian';
end
end

Categorie

Scopri di più su Entering Commands in Help Center e File Exchange

Tag

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by