1 of 2

Wise, 40 bytes

::^?[:::^~-&[-~!~-~-?]!-~?|>]|:[>-?>?]|~

Try it online!

Explanation

::^?                                      Put a zero on the bottom
    [                                     While
     :::^~-&                              Get the last bit
            [-~!~-~-?]!-~?|               Increment counter if 1 decrement if 0
                           >              Remove the last bit
                            ]|            End while
                              :[>-?>?]|~  Get the sign