Using $sformatf in an if condition!

Hi All,

I was wondering if there is a way we can use $sformatf in an if condition? I tried using it as shown below

module run_module();
  int i=1;
  initial
  begin
    if(i == $sformatf("%d",1))
      $display("worked");
    else
      $display("dint work");
    $display(i);
    $display("%d",1);
  end
endmodule : run_module

By running the above code I get the following output :
didn’t work
1
1

There are no errors or warnings but somehow the behavior is not what I expected. Can someone explain if this is possible?
Thanks

In reply to szy0014:
You should have gotten an error, but in any case what where you expecting it to do?
You are trying to compare the value of an int with its ASCII formatted string representation which is the following in hex bytes: 20 20 20 20 20 20 20 20 20 20 31 (20 is the code for ’ ’ (space), and 31 is the code for ‘1’)