I've been asked this question a few months ago when I was interviewed by Google, She wanted a smart way so I told her that I can use the calculator but probably that's not the answer that you want. I decided not to answer.
My idea was to multiply 2 by 2 by 2 by 2 ....... until I reach 2 gigs.
Yesterday I was going home and I don't know why did I remember this again.
I tried to solve it using binary shift and so but it didn't work.
Guess what ? An idea popped into my head, What if we take the logarithm of 2 gigs to the base 2 ?
Now that's a damn smart answer, It takes a bit of concentration to get it and when you realize that it's a simple answer you might get mad at yourself.
That's why I'm sure that I'll fail in IQ tests although I'm sure that I'm smart :-)
Looks like I failed and they didn't contact me again!












Hey, since 2^10 is kile, 2^20 is Mega, then 2^30 is Giga
So the unser must be 2^31
this is basic algebra ... not "damn smart".
and i can't believe you thought about binary BEFORE thinking about this one.
I don't understand how is rephrasing the question an answer?
well, I know that that max value that can be put in a signed integer(when an integer is 4 bytes) is 2 then 9 digits(I don't remember the number ofcourse), a gig is also 1 then 9 digits, so that's, now I now the number.
knowing that a signed integer contains a sign bit on the left, then 31 bits are remaining, so that's the answer.