avoid undefined behaviour from `sqrt`