Here is Minkowski's question mark function:
It is a strictly increasing and continuous function from the reals to themselves that, among other unusual properties, maps rational numbers to dyadic rationals (those with a power-of-two denominator). Specifically, suppose the continued fraction representation of a rational number \$x\$ is \$[a_0;a_1,\dots,a_n]\$, then $$?(x)=a_0+\sum_{i=1}^n\frac{\left(-1\right)^{i+1}}{2^{a_1+\cdots+a_i-1}}$$ For example, 58/27 has continued fraction representation \$[2;6,1,3]\$, so $$?(58/27)=2+\frac1{2^{6-1}}-\frac1{2^{6+1-1}}+\frac1{2^{6+1+3-1}}=2+2^{-5}-2^{-6}+2^{-9}=\frac{1033}{2^9}$$ so the pair (1033, 9) should be returned in this case. Similarly for 30/73 with expansion \$[0;2,2,3,4]\$: $$?(30/73)=2^{-1}-2^{-3}+2^{-6}-2^{-10}=\frac{399}{2^{10}}$$ and (399, 10) should be returned here. Note that it does not matter whether the form ending in 1 is used or not.
Task
Given a rational number \$x\$, determine \$?(x)=a/2^b\$ as a rational number in lowest terms (so that \$b\$ is a non-negative integer, as small as possible, and \$a\$ is odd unless \$b=0\$) and output \$a\$ and \$b\$ (not \$2^b\$). \$x\$ may be taken in any reasonable format, and if you take a pair of integers you may assume the corresponding fraction is in lowest terms.
This is code-golf; fewest bytes wins.
Test cases
x -> a, b
0/1 -> 0, 0
1/1 -> 1, 0
1/2 -> 1, 1
-1/2 -> -1, 1
2/1 -> 2, 0
1/3 -> 1, 2
1/8 -> 1, 7
2/5 -> 3, 3
8/5 -> 13, 3
58/27 -> 1033, 9
30/73 -> 399, 10
144/89 -> 853, 9
-17/77 -> -767, 13
-17/99 -> -133, 12
355/113 -> 12648447, 22
16000/1 -> 16000, 0
?(x)
I’ve seen only deal with positive numbers. Of course I turned on the negative validation, but I think it’s unnecessary! \$\endgroup\$