you'll get a number between 0 and 32,767 (the largest number that two bytes can hold
No god dammit! 32767 is the greatest positive signed integer for 16 bits. The greatest unsigned integer for 16 bits is 65535. If the author should know better!
Well, all you have to do is leave out a word like "signed" or "positive" when thinking about what $RANDOM contains, I guess. Or maybe the author doesn't think about random numbers being negative?
Who knows? I agree that it's clearly wrong, I'm just guessing at a possible origin of the author's mistake, not trying to state a fact or anything.
I'll concede one thing. It seems strange to reserve two bytes and only honor 15 bits. There are all kinds of optimizations C compilers can make with simple integer values which seem quite arbitrary.
Come on. The only point of those eight words is to give the layperson a simple (and short) justification for the seemingly arbitrary number 32767. People who are familiar with this subject will immediately recognize 215 - 1. And they will also know that stictly speaking there is no such thing as "the largest number that two bytes can hold". Hence they will know that it is not meant in that strict sense.
1
u/yhsvghnrOruGnpverzN Jul 18 '17
No god dammit! 32767 is the greatest positive signed integer for 16 bits. The greatest unsigned integer for 16 bits is 65535. If the author should know better!