How to handle the variable in the task

I am trying to write a task as shown below. the variable count is decreased each time in the while loop but when we jump out this loop, the variable count is not zero, May I know how to handle it ?

task read_check(logic [19:0] addr, output logic [31:0] rd_data, input logic [31:0] expect_data, uint32 count);
    while(count--) begin
        register_read_addr(addr, rd_data);
        if(rd_data != expect_data) begin
            `uvm_info(get_type_name(), "not matched now", UVM_LOW);
            wait_cycles(10);
        end
        else begin
            `uvm_info(get_type_name(), "matched!", UVM_LOW);
            break;
        end
    end
    if(count == 0) begin                //  <==  I thought it should be zero but it isn't...
        `uvm_error(get_type_name(), "finally NOT MATCHED");
    end
endtask :read_check

In reply to zz8318:

Please use code tags to make your code easier to read. I have added them to your post.

count-- evaluates count first, then decrements. --count would decrement count first then evaluate. Whith your code I would expect count=='hFFFFFFFF if the break condition is not hit.

In reply to dave_59:

oh, It’s so stupid of me to make this kind of mistake… Thanks for your quick help