Adding Hexadecimal numbers?
古いコメントを表示
Can someone help me how to add 2 hexadecimal numbers? I would appreciate the help and sentiment.
I tried using: c=dec2hex(hex2dec(a)+hex2dec(b)));
But it didn't work. Is there a correct way to do this?
採用された回答
その他の回答 (2 件)
Steven Lord
2019 年 10 月 17 日
>> 0x3afb + 0x2839
ans =
uint16
25396
>> hex2dec('3afb')+hex2dec('2839')
ans =
25396
Walter Roberson
2019 年 10 月 17 日
1 投票
If there is a possibility that the user might enter hex values with more than 53 significant bits then you should use sscanf with %lx format instead of hex2dec.
カテゴリ
ヘルプ センター および File Exchange で Environment and Settings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!