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

21 次查看(过去 30 天)
Is there a function to tell if Matlab is using little-endian or big-endian on current computer?

采纳的回答

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

更多回答(1 个)

Matt J
Matt J 2024-12-17
编辑:Matt J 2024-12-17
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

类别

Help CenterFile Exchange 中查找有关 Entering Commands 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by