Difference between %3d and %03d in sv or uvm

module
//strings
initial
begin
for(int i=0;i<5;i++)
begin
$display(“value of i=%3d”,i);//difference between %3d and %03d
end
endmodule

In reply to tgs:

For your example there is no difference.
See the your code example slightly modified:

module top;

initial begin
for(int i=0;i<105;i++)
  $display("value of i = %3d :: i = %03d",i, i);//difference between %3d and %03d
end
endmodule

But there is a difference in the following example:

module top;
initial begin
for(int i=0;i<105;i++)
  $display("value of i = %h :: i = %0h",i, i);//difference between %3d and %03d
end
endmodule

%0h is skipping all leading ‘0’.

In reply to tgs:

Hi just take out the fallowing snippet and note the result given for different scenarios.

 module top;
integer i;//You can use any data type you want

initial
 begin
   i=2456;//Some unsigned integer value assigned to variable i 
   $display("Value of i=%3d, i====%03d, i=%0d",i,i,i);
   #10;  
   i=24; 
   $display("Value of i=%3d, i====%03d, i=%0d",i,i,i);
 end
endmodule

result:

@time=0

Value of i=   2456, i====2456, i=2456

In the above result for first “i” variable “i=%3d” means the “i” value has to be print after 3 space character, second “i” variable “i====%03d” means zero(0) represents no white space character for displaying the “i” value and here 3 represents the value of “i” should be fitted in 3 character space only, that you can check in the @10 time unit delay result, and “i=%0d” means without any white space character the “i” values has to be printed.

Result:

"time=10

Value of i= 24, i====024, i=24

In reply to Sriram Yalavatti:

thank you bro

In reply to chr_sue:

thank you sir