ITsecurity
twitter facebook rss

Divide by Zero Cookie Intolerance

Posted by on July 6, 2015.

Once upon a time – I guess it was in the late 1980s – a band I was in got into a debate over what we should call ourselves. I’d fairly recently switched from the building industry to the IT industry, and had become totally hooked on programming, which may explain why my own slightly Zen suggestion was ‘Division by Zero’. Yes, I know there is or was a Polish band with that name, but there wasn’t then… Anyway, I was outvoted.*

Still, decades on I was fascinated to read that The internet is obsessed with what happens when you ask Siri “what’s zero divided by zero?” It turns out that Apple’s virtual personal assistant thinks that’s a silly question and gives you an accurate enough but somewhat brusque response:

“Imagine that you have zero cookies and you split them evenly among zero friends. How many cookies does each person get? See? It doesn’t make sense. And Cookie Monster is sad that there are no cookies, and you are sad that you have no friends.”

Ouch! Well, maybe if you’re easily offended by an automated response, you’d better not ask the question. But the chances are that people have been interested in seeing/hearing the meme of the week rather than the real answer to the question, which is (literally) indeterminate, mathematically speaking. I’m not going to attempt to explain it because, frankly, my understanding of calculus doesn’t go much beyond being able to spell it.

However, 0/0 is actually a special case of division by zero. While Siri does offer a commonsense-ish explanation of why you can’t divide zero by itself, and you can certainly argue that in terms of everyday arithmetic, there isn’t much you can do with a number divided by nothing that you can’t do with a number that isn’t divided at all. However, there is actually a more formal reason why you ‘can’t’ divide by zero.

From a programmer’s viewpoint, though, there are practical issues. Calculators are normally programmed to return a ‘Divide by Zero’ error where a / is followed by a 0 followed by an =. In fact, many programming languages are specifically designed to prevent an illegal ‘Divide by Zero’ operation because the result of the operation is unreliable (to say the least). Sometimes, this will result in a compiled program grinding to a halt with an inscrutable error message along the lines of ‘ runtime error [numeric code] at [segment]:[offset]’ which can be very embarrassing for the programmer, especially one who may have no idea what he’s done to initiate an arithmetical operation. While I’m absolutely not a mathematician – and was never primarily a programmer – I did enough coding (some of it math-related) at that time to learn the hard way that sometimes you need to do some of your own exception handling in unexpected contexts. A program that crashes out with an error code is fine when you’re debugging it, not so fine when it does so out in the real world.

What does this have to do with security? Well, the accuracy and integrity of data certainly concern those of us working in security, and an unreliable application – well, any application may fail if the right combination of the wrong circumstances arises – can certainly give you a nasty shock with a high impact. Reportedly, in 1997 the USS Yorktown suffered a systems failure due to a divide-by-zero error in a Windows NT application that left it dead in the water for two and three-quarter hours. One contributor to the RISKS digest observed that:

Ideally, the next few generations of operating systems will end up being so incompatible with legacy systems that no country anywhere will be able to wage war.

David Harley

*I know you’ve only read this right to the end in the hope of finding out what we did call ourselves, so let me quench the fires of curiosity. We became the Flying Piglets. When I tell people that (not very often) they tend to say “Oh… you were quite famous then.” Evidently I need to improve my enunciation: the Flying Piglets (not to be confused with Three Flying Piglets) weren’t nearly as famous as the Flying Pickets.


Share This:
Facebooktwittergoogle_plusredditpinterestlinkedinmail

Leave a Reply

Your email address will not be published. Required fields are marked *

Submitted in: David Harley | Tags: , , ,