Limited Interest

A Useless Bug in a Calculator

Technical

My favourite calculator has a bug in the input display. It allows for some fun overlapping of text on the display, as well as an invisibility trick.

First I will start with some background, however since background is boring skip to the interesting things here. If I haven’t added more yet, it should be sufficient to skip two paragraphs. Or just look at the oversized images.

Introduction

I have recently been reminded by a change in policy by my university to allow some other calculators to be used in exams that I have a calculator that has what can possibly be described as a bug. By some I mean not this one, this one is not on the list. I wish it was because it is my favourite basic scientific calculator. I first got it when I went to high school and it has served me well since. It was during the final years of high school that I discovered this bug during a maths exam, and wasted most of that exam exploring what it could do.

Because I will be describing what this bug is and how it works I will need to include some pictures, which right now is a pain because due to it’s advanced age the batteries in it have finally run completely dry. So if you’ll excuse me for a moment I need to get some batteries for this thing.

Be Interesting

The calculator is the SHARP EL-W531. The bug is in the display of the input, the output is still fine. The bug is displayed in the image below.

A photo of the display of a calculator showing a right bracket overlapping with an S symbol. It shows 'open bracket, A, N, S overlapped with a close bracket, squared symbol'.

The calculator showing the bug in a basic form, will be discussed in full.

Because that can be a bit hard to see, I will convert the image into just a display of the pixel data, like shown below.

Same as the previous figure, but rather than a photo it's shown as the pixels from the display. It shows 'open bracket, A, N, S overlapped with a close bracket, squared symbol'.

Calculator input as pixels, as will be shown frequently from now on.

But what is that showing? It’s showing (ANS²) but the right bracket and the S from ANS are overlapping.

Now I don’t know how hard this will be to illustrate, but I will give it a go. So first is how the square operator works and displays on the screen.

Pixels from the input of a calculator. It shows 'open bracket, box, squared, close bracket'. The box signifies that the squared expects a value to be placed in it.

The squared symbol has a box in front of it to show that it will square the value in the square should there be something in there.

When a number is entered in this place, it works as expected. However, when ANS is answered, the square symbol is in the expected position, but the right bracket only moves as it would if ANS was 1 character long. Hence the S from ANS overlaps with the right bracket. Additionally if the squared symbol is deleted, this bracket remains 2 places in front of where it should be, now over the N.

Pixels from the input of a calculator. It shows 'open bracket, A, N overlapped with a close bracket, S'.

Deleting the squared symbol moves the bracket back one character.

ANS can then be deleted, the right bracket is now in a very weird position, this causes neither to render at all. I don’t think I need to include a picture of what this looks like. If you place a symbol inside the bracket, this displays as normal. If you then place a symbol outside the right side of the bracket, it places it on top.

Photo of the input of a calculator. The calculator input is showing 'open bracket, plus symbol overlapped with a multiplication symbol, close bracket'.

The actual calculator again, with a + and × symbols overlaid using the technique described above.

Performing this technique twice in one bracket allows for a single symbol to be hidden off the left of the screen. This leads me to a stupid thing (as if the rest of this isn’t stupid), π = 3.

A photo of the display of a calculator, the display is showing 'pi equals' in the input and in the output it is showing '3'.

Irrefutable proof of the well known identity.

The full input of the display would read (A)×π, should the input not be strangely shifted.

Why?

I don’t know how the code is written, but I’d imagine it’s something to do with an optimisation made to make rendering brackets quicker. Rather than recalculating the position of the brackets every time, it instead keeps track of how much the inside of it expands and contracts by and uses that information to come up with where to position itself. If ANS is placed inside a square, the bracket is told to increase by 1.

If something is placed or removed from a bracket that changes the height of the display, for example a fraction or a general power, a full recalculation on the position of the brackets is performed. This places them back in the correct positions.

Additional details

This doesn’t only work with brackets, it also works with square roots! If this is done to a square root, removal of the square and ANS will make it disappear. This can also hide a single symbol inside it.

However, far more interestingly, if you place a symbol in front of the square root…

A photo of a calculator. It is showing '0, square root, box' however the bar of the square root that extends over what should be square rooted extends off the right side of the display.

I have no idea why this happens

… that happens.