How to use $sprintf - with field width and not padding

In reply to snognogt:

HI,
I’m trying to use $sformatf(“0x%X”, my_number)
my_number is 8 bits number and i want sformatf to print this number is 2-digits width field and no leading “0”.
how can i make it ?
Thanks !

Can you provide an example of what you want to display?
What you have is that if my_number = 8’h24. Your sformatf will return a string that is “0x24”.