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

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

sprintf('0X%.2X', 0)

1 Comment

Thanks Roberson. I thinks that '0X%.2X' does not work in high-level functions but this works correctly.

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

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

Start Hunting!