Implement a function that computes x raised to the power n, where n can be any integer (positive, negative, or zero). Meta interviewers use this to test your understanding of binary exponentiation and edge case handling.
For example, pow(2.0, 10) returns 1024.0, and pow(2.0, -2) returns 0.25.
A naive loop multiplying x by itself n times gives , which fails for up to . How can you compute the result in multiplications?
Constraints: , .