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

22 ビュー (過去 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 Center および File ExchangeEntering Commands についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by