2 1 byte off
source | link

Wise, 4040 39 bytes

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

Try it online!Try it online!

Explanation

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

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

Wise, 40 39 bytes

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

Try it online!

Explanation

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

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