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

The Black Magic of Getting Your Book Tweet Right

I’ve been doing this book marketing thing for quite a while now, and one thing that I often need to help people with is getting their book link tweets right. I figured it’s time for me to put all my tricks in one place. This is that place.

“People click my link and it says the book isn’t available”

The problem here is that there isn’t just one Amazon. There are lots and lots of them. If you share a link to amazon.com, and someone in the UK looks at that link, they’ll see your book, but Amazon won’t let them buy it. They need to find your book at amazon.co.uk. But they aren’t going to do that, are they? It’s a minor miracle that you got them to click your link in the first place. No way they are going to go typing in a search to a different website to find your book in the right store. Not. Gonna. Happen.

The solution (which I’ve mentioned before) is to use mybook.to (there are other services, but I like this one best). It’s basically a link shortening service like bit.ly, but it is smart about geography and all those Amazon stores. It looks at where the person is clicking from, and sends them to the right place. Also, because they haven’t been around for 100 years like bit.ly, you can get pretty much whatever short link you want. I’ve never had any trouble getting the exact titles of my books as my short link.

Their links work for both Kindle and paperback books, so if you’re doing both, you’ll generate two links. These are the links I use:

When you set up the link you want to make sure that the Amazon link is like this:
https://www.amazon.com/dp/{ASIN or ISBN}
Be sure to use https (not http) and you don’t need your title in there. If you copy the link from Amazon, just delete the junk between .com and /dp and if there’s junk after the ASIN/ISBN, delete that, too. Obviously you should test the link to make sure you didn’t delete too much.

“I messed up and put in the wrong link, how do I fix it?”

After you create the link at mybook.to and you test it, if you find that you messed up and didn’t put the right link in there, you can fix it as follows:

  1. Delete the short link you created
  2. Create the link again, not making a mistake this time
  3. Go to this address mybook.to/clear-link-cache.php?url={your nickname} for example, if you created mybook.to/warandpeace you’d need to hit mybook.to/clear-link-cache.php?url=warandpeace

That’s not documented anywhere. The nice guy who administers the site told me that trick when he and I were debugging another problem which I’m about to tell you about.

“My tweet doesn’t have the preview of my book!”

So you’ve created your short link and tested it and it works great. Now you tweet it, but all that shows up is the short link, not the pretty cover and blurb and star rating from Amazon (known as a “Twitter Card”). Why is that?

This happens because when your book is brand new, Amazon doesn’t generate the right “meta tags” on the page for the Twitter card. No idea why, but it pretty much never does. So you have to hit the page over and over, and eventually it starts generating the right tags. But there’s a catch. Twitter saves the first version of that page it sees, so even once Amazon is generating the right meta tags, Twitter ignores them.

You can actually address both of these problems with one simple trick! There’s a tool that developers use to make sure their meta tags are good. You can use this tool to both force Amazon to re-generate the page, and to force Twitter to pay attention to the changes.

Go here: https://cards-dev.twitter.com/validator and enter the mybook.to link. Be sure to start with http, like http://mybook.to/warandpeace. If you forget the http, it won’t work, and the error message is confusing. Click the “Preview Card” button and you’ll either see a card, or you won’t. If you see the card, you’re done.

If you don’t see the card, count to ten and click preview card again. No card? Count to ten and click it again. You may have to do this many, many, many times. Trust me. This will eventually work. Once you see the card, you’re done. Go look at Twitter and you’ll see that the tweet which didn’t have the card, now suddenly does have the card.

“You didn’t answer my question!”

Ask in the comments. I can probably help.