Prescribing the binary digits of squarefree numbers and quadratic residues (Transactions of the American Mathematical Society, 2017)