How can I convert zero number to modified hexadecimal in formatting strings?

4 views (last 30 days)
IN THE NAME OF GOD
Hi.
>> sprintf('%#.2X', 0)
ans =
00
but I want a modified hexadecimal such as following:
ans =
0X00
Note: This works correctly for positive integers. See bellow:
>> sprintf('%#.2X', 1)
ans =
0X01
Thanks.
Mosakazemi

Accepted Answer

Walter Roberson
Walter Roberson on 24 Dec 2013
sprintf('0X%.2X', 0)

More Answers (0)

Categories

Find more on Cell Arrays in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!