" Simultaneously, I quickly Googled ‘how to use bitwise operators in C’ and found this wonderful code snippet on StackOverflow that made the problem easy to solve. I wrote a solution with time to spare, and the interviewer seemed content with my answer." Wow. NB to all interviewers: this guy's a cheat.
I would have to disagree that what I did was "cheating". Software engineers are given problems to solve, and their job is to solve these problems efficiently. You don't always have the solution to every problem off of the top of your head. That's why programmers use Google, StackOverflow, and documentation as resources. The primary skill employers are looking for is learning how to learn new things quickly. And I bel…
That's a pretty important part of the story, and makes the situation very different. It also makes the interviewer seem a lot more competent. Trivia questions are useless in interviews, and the fact that you were able to quickly google it, recognize it as a relevant solution, and apply it correctly actually is demonstrating that you know how to learn things quickly (and that you have at least some familiarity with binary representations and manipulations). The average charlatan would just start copying and pasting in panic, which is usually pretty easy to pick up on.
Meanwhile, you can't pretend what you described in your post is really a moral position if you had not said anything. It might not have been strictly immoral as you really owe them nothing, but there's no shining principle demonstrated there.