News for hackers. Stuff that matters.
Re:Fast midpoint between two integers without overflow by mostlylurks on Wednesday December 07, 2022 @11:49AM (#33896653)
> think the range of an the int type is, I quote [...] "65 thousand-something"

Whether or not this is a completely ludicrous answer depends entirely on how you presented the question (i.e. whether or not it was clear that you're talking about java instead of asking a more general question).

For example, in C, the int type can be as low as 16 bits in size, yielding "65 thousand-something" possible values in the worst case. So that could be a reasonable answer as the guaranteed range of values for an int. And even in an android interview, C(++) can conceivably be the assumed context if the previous questions have been NDK-related.

> Let alone it's not even a range!

I feel like it's not a particularly uncommon shorthand to refer to the extent of a range of values that something can take as "the range" of that something.

Re:Fast midpoint between two integers without overflow by a1369209993 on Wednesday December 07, 2022 @04:49PM (#33900775)
> in C, the int type can be as low as 16 bits in size, yielding "65 thousand-something"

Wrong both for worst-case C and for "16 bits in size": the actual maximum is "32 thousand-something" (specifically 32767 in 2s-complement and also in most of the stupid representations (like 1s-complement or sign-magnitude), although there might be some that have, eg, 32768). They also have a minimum of -32768 (or -32767 or otherwise for some of the stupid representations).

You could intepret it as "65 thousand-something" values between the minimum and maximum, but that strongly implies that the minimum doesn't need to be specified, which only works for unsigned integers (which C int is very much not).

Re:Fast midpoint between two integers without overflow by mojuba on Wednesday December 07, 2022 @02:59PM (#33899413)
The question was: what is the range of possible values of the int type in Java? (In the context of finding the middle problem)

"256" is a ridiculously bad answer on multiple levels. Believe me, I heard it from more than one Java developer with a CS degree and at least 5 years of experience at the time.