You have 10 seconds
I was walking along the Orchard Road (a busy “consumercial” street) in Singapore. There was this guy who approached me with maybe 2 pieces of paper and a blue plastic envelope/bag in his hands. He looked a bit flustered, and started talking to me and pointing to the top piece of paper.
I heard words such as “help”, “ex-convict” and “get jobs”. I saw the word “ex-convict” on the piece of paper he’s pointing to. The foremost thought on my mind was, “what does he want me to do?“. Do I need to sign a petition? Do I donate some money? Do I have to give out contact information?
After, I don’t know, 30, maybe 40 seconds, he finally got to the point. “Please donate.” And that’s what the plastic envelope was for. I’m not sure if you’ve seen this. It’s a flat carrier, with a small slit near the handle on top, large enough for coins to be slotted. You can even slot dollar notes if you fold them a little.
I donated some money and I was off. I am aware of this movement; I read some poems written by inmates on those service tray paper in Coffee Bean. It’s the Yellow Ribbon movement in Singapore.*
There was another incident where I was having lunch with my colleagues, and this young lady approached us and started her conversation with the words “I’m not here to sell you anything”. Loosely speaking, she was selling us something. I’ll get to that in a moment.
I can’t even remember what she was representing. She pointed to her badge hung around her neck, said something to the effect that she’s authentic and real and part of an authorised movement. She started talking about her cause. For, I don’t know, 30, maybe 40 seconds.
Then she got to the point. “Please donate”.
I have every respect for your cause. I empathise with the people you want to help. I also treasure my time very much. So please tell me exactly what you want me to do, and then tell me why I should do it.
Get to the point
Let’s look at this in a simple situation. A tourist asking for directions. “Hi there, I’m kinda lost. Can you tell me how to get to such-and-such building? I’ve been walking up and down this street for a long time.”
Short, simple and under 10 seconds. From your look, your mannerisms, your dressing, your behaviour and then with your question in context, I have already made up my mind about what I want to do with you. Say a stranger walked up to me, and from appearances I could guess he’s a tourist. Facial expressions and body movements suggested tiredness and slight frustration. I could probably tell if he’s lying, if his words matched his outward appearance.
Frankly speaking, when the stranger walked up to me, I probably already decided that he’s lost and he’s going to ask me for directions. And I’ve already decided to help him if I could. Verbalising the question was just a formality.
What happened for the 2 people above was that, when they approached me, I’ve already made many unconscious decisions and arrived at an answer. They were asking for donations, and maybe spread awareness of some kind. They were asking for help.
I’ve already decided they’re probably asking for donations, and I was waiting for them to confirm that. I could be wrong. So I waited for them to tell me if they wanted a donation, and if it was, what was I donating to.
I waited and waited. I didn’t interrupt them since it would be rude. And waited for 40 seconds. I was deciding if I wanted to donate, and what else they wanted with me. And that thought occupied my entire thinking process while they were trying to educate me about whatever it was they stood for.
Make it simple and painless
Look, it’s hard to approach someone as a stranger, and start trying to educate that person about something within minutes. That person is already busy trying to figure out what you want with him. You’re making it harder by introducing a concept that might possibly be unfamiliar to the person.
Now, this might sound a little odd. Anytime you ask for something, you’re actually selling something. It’s just that sometimes, your price isn’t monetary. In fact, if you’re reading this far, I’ve already sold you something. I sold you information, and it’s free. In monetary price anyway. The price was actually your time, your attention. And it’s very valuable to you and to me.
For donations, the product being sold is the feeling of helping someone or a cause.** It might sound materialistic and cynical. It took me a while to wrap my brain around this. If it helps take the edge off, you can think of the product sold as just helping someone or a cause.
Donations obviously have a monetary price tag on it. Is there a need for people to pay with time and attention too? There are empathic people. There are also empathic people with busy schedules and limited time. You can spread awareness about your cause in another fashion. The street is not the most conducive environment to do it.
There’s something I read, written by David Eddings. It’s fiction, but I think it has real life roots. Eddings wrote about this beggar. The beggar was obviously asking for donations. The “trick” was to get the message across, and make it as painless for the donor to donate as possible. A missing leg, dressed in rags, covered in dirt, and crying out “Charity!” in the feeblest, most pathetic voice while sticking out a donation bowl worked wonders.
The wordless exchange
There’s another incident where I was having my meal at a diner. It was relatively empty, only another lady and me. A person walked into the diner and laid something on that lady’s table. “I’ve seen this before.” was my first impression. And that person came over to me and laid something on my table too. It’s a card and a key chain, shaped like a key. The card read something to the effect of “I’m dumb and please buy this key chain from me.”.
When that person walked in and placed something on that lady’s table, I already came up with an image. A dumb (as in unable to speak) person asking people to buy something, almost like a donation. That person placed his card and key chain on my table, and left. His body movements, and my previous memories of similar encounters, and the card told me everything I needed to know. And I knew what he wanted, to buy his key chain (in this case).
He didn’t stay to explain his situation. He didn’t have to explain his cause. He couldn’t tell me even if he wanted to. Yet within seconds, I knew what he wanted me to do.
He returned after a while, and came to retrieve the cards and the key chains. If the person wanted to buy, great. If not, he’d just collect his card and key chain.
He came to me. I bought his key chain. I took out the required amount and handed the money over to him. He took out a set of key chains and gestured. Oh, I get to choose the colour, and chose gold. He took out a new gold key chain, and handed it to me. Then he took out another card and showed it to me. Oh, it acts as a bottle opener too.

I smiled at him. He smiled back, and then left. I didn’t feel stupid at all, despite some fumbles over communication, despite the fact that no words were ever exchanged. I felt good.
Impassive interface
Human face-to-face interactions have the benefit of facial expressions and body movement to add context. With computer programs, your users miss out on this benefit. Suppose the user already know what the interface is for, for example, an online sales order form. Is the interface intuitive enough that the user knows what he needs to do next?
I’m not talking about people who have the attention span of a gnat, who clicks away within 2 seconds if the web page doesn’t load fast enough, or the initial look isn’t interesting enough. I’m talking about people who already know what they need to do, and why. I’m talking about people on that web page, or program interface, and they are confused about what they need to do to make what they want happen.
Make the steps they need to do obvious. Make the text fields and required input format obvious. Have appropriate text for action buttons. Some of these people could be busy on the phone, attending to customers. The last thing they need is a confusing interface. Make it obvious to them what they need to do.
Because on the screen, you have 10 seconds to tell them what to do.
* I went to the web site, and it turns out there’s a pop-up warning about donation soliciting on streets. Maybe I was conned?
** There’s this idea that when you buy, you’re actually buying a feeling. That car you bought? You’re buying the feeling of freedom, of convenience, of status. That dinner you bought? You’re buying the feeling of staving off hunger, of being satiated. Just a different perspective.
Encryption, bijection and reversibility
The whole point of this article is to tell you that you need to write reversible programs, or programs with results that are easy to undo. There, you’ve got the point. That’s it.
You still here? Then get ready for a bucket-load of concepts below.
The swap
How do you change DAN from a him to a HER? Add 4. Suppose you have the entire alphabet on one row and another set shifted by 4 placings:
ABCDEFGHIJKLMNOPQRSTUVWXYZ EFGHIJKLMNOPQRSTUVWXYZABCD
Can you see the correspondence? We can even undo the sex change, reversing HER back to DAN.
This is one of the simplest forms of encryption. It’s also easily broken with the use of computers (and programming of course). Still it illustrates the concept of changing something that’s RIGHT to something unintelligible like VMKLX.
The whole point of encryption is to scramble a plain text message into something obscure so no one except the intended can read it. There’s no point in having an obscure message without being able to get the plain text message back, is there? So encryption has to be reversible.
Now we’re going to do math.
Please, no trees
Let ALPHA be the set of all 26 English alphabets in upper case. Suppose a function F behaves such that if F(x) equals F(y), then x must be equal to y, where x and y belong to the set ALPHA. Then the function F is said to be injective.
Using the encryption model above, where our function F swaps the letters from the top row to the letters in the bottom row, let’s have the final letter be D. There’s only one letter that can map to D, and that’s Z. F is injective.
It might be a bit hard for you to visualise that. Let’s use the contrapositive version of the statement. If x not equal to y, then F(x) not equal to F(y). So if P not equal to Q (which is true), then F(P) = T which is not equal to U = F(Q).
Injectivity is a one-to-one relation. No tree-like structure, no linking of nodes, no multiple results from the same starting point, no multiple starting points ending in the same result.
Must start somewhere
Let ALPHA be the set of all 26 English alphabets in upper case. Suppose a function F behaves such that for every letter y in ALPHA, there’s another letter x in ALPHA such that F(x) = y, then F is said to be surjective.
Using the encryption model above, every letter in the bottom row has a corresponding letter in the upper row. So our function F that swaps the top letter to the bottom letter is surjective.
Surjectivity is a there-exists-a-starting-element concept. On a philosophical note, your life journey can be likened to surjectivity; you started somewhere didn’t you?
Two way street
A function F is said to be bijective if it is both injective and surjective. It is one-to-one, and for every destination, there’s a starting point. So you can go back and forth in a unique manner without fear of getting lost.
Bijections allow reversibility. Encryptions are bijections. Thus encryptions are reversible. Actually, I just thought I’d introduce you to the concept of encryption and bijection. Their relation to reversibility is hand-wavily tenuous… But I’m forging on anyway, so…
Can you write a bijective program?
I would have to say no, in general. There’s usually more than one way to do something, and that violates the injective rule. But if you conform to a stricter set of rules, you can approach the situation where there are fewer ways of writing code to do whatever you need done. So you get an almost injective state. Then you get a reversible program under strict rules.
What’s the whole point of this? A program whose results can be easily reversed is useful. Suppose the result isn’t satisfactory. Do you need to do a lot to undo that damage? A computer virus is (generally speaking) not useful. It’s effects are not easily reversible. In fact, its intent is to be as irreversible as possible.
A reversible program, a program that you can rerun with minimal fuss and effort. That’s useful. Why would reversibility be useful?
Because it allows humans to make mistakes.
And we will make mistakes, make no mistake about that *smile*. When users make a mistake, how have you written your program so it’s easy to recover from it?
Only quarters counted
Last week, at the end of the article, I presented a problem on floating point values:
Given the range of non-negative 2-decimal-point values less than 1, what are the values that can be represented exactly?
I was referring to dollars and cents, monetary values. As of this writing, there’s no answer submitted. I will assume that you’re very modest, and so will provide my version of the answer. First, we dissect the question. “non-negative” means cannot be negative, so zero and positive numbers only. “less than 1″ means, well less than 1. And the values are restricted to numbers with up to 2 decimal points of accuracy.
So this means the set of values 0.00, 0.01, 0.02 … 0.97, 0.98, and 0.99 (1.00 not counted).
Before writing this article, I already an answer, intuited without actual calculations. Then I went to do some research of mine to verify that answer. I was mortified that my understanding of the IEEE floating point standard was wrong. I dug up my old university programming textbook, where there’s a section on internal floating point representation, and confirmed my misunderstanding.
My error was in how the exponent and mantissa were represented. In the end, I realised I had to convert all the 100 values (0.00 to 0.99) into binary representation to check. I didn’t relish doing long division by hand for a possible indefinite number of iterations (up to 32 anyway), and for 100 values. So I took the easier way out. I wrote a program. *smile*
decimal decBinary = 0.5m;
decimal decBuffer = 0;
int i, j;
for (i = 0; i < 100; ++i)
{
decBuffer = i * 0.01m;
Console.Write("{0} ", decBuffer.ToString("f2"));
decBinary = 0.5m;
for (j = 0; j < 32; ++j)
{
if (decBuffer < decBinary)
{
Console.Write("0");
}
else
{
Console.Write("1");
decBuffer -= decBinary;
}
decBinary /= 2;
}
if (decBuffer != 0)
{
Console.WriteLine(" non-terminating");
}
else
{
Console.WriteLine(" terminated");
}
}
It's in C# and there's not much comments. But you should still be able to follow much of the code, even if you aren't familiar in C#. This is assuming a 32-bit is used to represent a float. I ran the long division iteration up to 32 times, even though in a real representation, only 23 bits are used. Here's a Java applet IEEE binary converter you can play with too.
What happens is that, if after 32 bits are assigned (a 0 or 1), if more bits need to be assigned (not terminated), then the floating point representation isn't exact (since there's extra information truncated). You will then note that only 0.00, 0.25, 0.50 and 0.75 have terminating binary representations. This means, only those 4 values can be represented in a float exactly.
So, what was my original intuitive answer? Let's look at only 4 binary places in the mantissa. So 1010 represents 1*2^(-1) + 0*2^(-2) + 1*2^(-3) + 0*2^(-4), which is 0.5 + 0.125 = 0.625
Look at the value with only the 3rd mantissa digit as 1, 0010. It represents 0.125 in value. How do you "get rid" of the 0.005 to get 0.12 or 0.13? You can't, not from switching on bits in any of the mantissa digits. So what does this mean? The moment the 3rd mantissa digit is a 1, the floating point representation can never represent any of the 100 2-decimal-point values exactly.
In fact, the moment any mantissa digit that's the 3rd or after (4th, 5th and so on) is a 1, that representation is inexact already. So only the 1st and 2nd mantissa digits are "allowed" to be 1. So 0000 is 0.00, 0100 is 0.25, 1000 is 0.5, and 1100 is 0.75.
Same answer as from my laborious calculations. Out of the 100 values, only combinations of quarters or 25 cents have an exact floating point representation.
I hope this has been an interesting thought process for you. Has this changed the way you think about storing monetary values?

