Hard Tweets Explained: NäN

In the early days of computers, pretty much the only thing everyone could agree on was how to represent small positive integers. Other than that, nobody could agree on anything. They couldn’t agree on how many bits were in a byte. Or how many bytes you should work on together (called a “word”). Or how the bytes in a word should be ordered (biggest to smallest, or smallest to biggest). They couldn’t agree on how to represent negative numbers (sign-magnitude or two’s-compliment). They couldn’t agree on how to map letters to numbers (EBCDIC or ASCII). And they really, really, really couldn’t agree on how to represent real numbers (the kind with decimal points in them).

Over time, all these arguments got settled. Except the word ordering one. They still can’t agree on that. And the final decision on how to represent numbers (both integers and real numbers) was worked out in a committee that produced the IEEE 754 standard. That standard even covers weird things like what’s the value of 1➗0 (+infinity), -1➗0 (-infinity), and what to do with equations that make no sense. For example, if you add +infinity to +infinity you get another +infinity. But if you add +infinity to -infinity, what do you get? It’s not zero. They dump all those strange cases into a bucket called “not a number.”

Think about that: In the standard for how to represent numbers, there’s also a standard way to represent things that aren’t.

“Not a Number,” abbreviated “NaN” is pretty easy to get. 0➗0 for example. Or you can get it by treating something that isn’t a number at all as a number, if you are using one of the modern languages that lets you make mistakes like that.

IEEE 754 didn’t only specify how to store a NaN in computer memory, but it also gave rules for how to handle it in equations. And one of the rules is that it refuses to be ordered. 0<NaN is false. But 0>NaN is also false. A weird result of that rule is that NaN cannot equal itself.

Suppose you are working with a computer language that uses === to mean “is equal to” (yes, such languages exist). In that language if you have a variable X and you test X === X, you’d think that had to be true. But it’s not when X is holding a NaN.

And that brings us to our tweet.

Nän (also spelled “naan”) is a kind of bread they serve in Indian restaurants. Funny story. I was once on a bus at work going from one building to another, and a new Indian restaurant had just gone in. And the bus driver said, “Hey, is that place any good?”

And I said, “Yeah.”

And the bus driver said, “So, what do they serve there? Like maize and buffalo and stuff?”

The bus driver was not joking. Sigh.

Anyway, I digress. So nän is a kind of bread, and NaN is a numberish thing that isn’t equal to itself. And unless you are that bus driver, I’m guessing you can put the rest of those pieces together.

And if you are that bus driver, I think you were one hell of a great bus driver, and I really appreciated you, and some day I’d like to take you to that restaurant for some nän.

 

Advertisements

One thought on “Hard Tweets Explained: NäN

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s