# Need to printing the values in binary with leading zeros

**URL:** <https://verificationacademy.com/forums/t/need-to-printing-the-values-in-binary-with-leading-zeros/47426>\
**Category:** SystemVerilog\
**Tags:** SystemVerilog, UVM, testbench, Verilog\
**Created:** [May 23, 2024, 11:48am UTC](https://verificationacademy.com/forums/t/need-to-printing-the-values-in-binary-with-leading-zeros/47426 "2024-05-23T11:48:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![SUNODH](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/sunodh/32/4411_2.png) [@SUNODH](https://verificationacademy.com/forums/u/SUNODH)\
**Post date:** [May 23, 2024, 11:48am UTC](https://verificationacademy.com/forums/t/need-to-printing-the-values-in-binary-with-leading-zeros/47426/1 "2024-05-23T11:48:28Z")

</div>

I was trying to create a file which tracks signals during simulation and print in a log file. So i am trying to capture REQ/ACK signals during simulation below is sample code

```auto
 always @(*) begin
      if (req !== prev_req || ack !== prev_ack) begin
            fh = $fopen(file_name, "a");
            $fwrite(fh, "@ %t | %0b | %0b \n", $realtime, req, ack);
            prev_req = req;
            prev_ack = ack;
            $fclose(fh);
      end
  end

```

So i am able to get prints in below is sample it was captured

> @ 93 ns | 1 | 0  
> @ 95 ns | 1 | 1  
> @ 97 ns | 11 | 1  
> @ 98 ns | 1000111 | 111  
> @ 99 ns | 1000111 | 1000111

but i need all bits status every time , like below

> @ 93ns | 000000001 | 000000000  
> @ 95ns | 000000001 | 000000001  
> @ 97 ns | 000000011 | 000000001  
> @ 98 ns | 001000111 | 000000111  
> @ 99 ns | 001000111 | 001000111

Is they is anyway i can do it ?

---

<div class="post-metadata">

**Author:** ![dave\_59](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/dave_59/32/4499_2.png) [@dave\_59](https://verificationacademy.com/forums/u/dave_59)\
**Post date:** [May 23, 2024, 2:30pm UTC](https://verificationacademy.com/forums/t/need-to-printing-the-values-in-binary-with-leading-zeros/47426/2 "2024-05-23T14:30:56Z")

</div>

Use `%b` instead of `%0b`. The `0` is asking to suppress leading 0’s
