## 50 EUR Challenge

February 20th, 2011 by Marek Kyncl

The first person (or computer) to figure out the algorithm which decides whether the pop-up version of the calculator will be displayed or not, who sends in the correct solution to ‘challenge [at] calculator-tab [dot] com’, will receive 50 Euros through Paypal from Calculator Tab.

## Change of button labels

October 25th, 2010 by Marek Kyncl

After a hint form Joyce Matthews (thanks!) I have decided to change the labels of the multiplication and division buttons to correspond to the standard labels on most calculators. The label for division is now “÷” instead of “/” and the label for multiplication is now “×” instead of “*”.

## Down Time

August 24th, 2010 by Marek Kyncl

I would like to apologize to anyone who has had problems with the site today. Due to technical problems, the site has been down, or only partially accessible throughout the day. Although the problem is now solved, I will be monitoring the situation more closely during the next few days to make sure any arising accessibility issues are solved as soon as possible.

## How can you tell whether your calculator follows the standard order of operations?

August 26th, 2008 by Marek Kyncl

A quick test that I use to find out if a calculator follows the standard order of operations is to enter:

1 + 2 * 3 =

If the answer is 7, then the calculator follows the standard order of operations, if the answer is 9 then it doesn’t. If no answer appears, then you are probably standing at IKEA trying to use one of the dummy calculators.

### Why it works

A calculator that does not follow the standard order of operations will apply the operators (plus, times, minus, etc.) as they come. In the above example, such a calculator would first add 1 and 2 (which is 3) and then multiply the result by 3 (which is 9).

A calculator that does follow the standard order of operations will first evaluate the “priority” of all operators in a calculation and then calculate the result evaluating the higher-priority operators first. In the above example the [*] operator has a higher priority than the [+] operator. Therefore the calculator evaluates 2 * 3 first (which is 6) and then adds 1 to the result (which is 7).

### The standard order of operations

The standard order of operations is a rule which states, that binary operators with a higher priority are evaluated before binary operators with a lower priority. The priorities are as follows:

1. Exponents
2. Multiplication/Division

For more information on the order of operations see this Wikipedia article.

## Accessing a Local Shared Object from multiple SWF files

August 10th, 2008 by Marek Kyncl

### The setup

Imagine you run a Flash calculator on your site, that can store numbers in a Local Shared Object (LSO), and have the great idea of adding a pop-up version of the calculator. After rolling up your brain sleeves and thinking about it for a minute, it becomes pretty clear that both versions will have to access the same LSO. There are mainly two reasons for this:

1. In the pop-up version the user will want to have access to the numbers she has already stored in the main version.
2. Numbers stored in the pop-up version should become available to the main version.

“That’s an easy one”, you think. “Since I’m already using the

SharedObject.flush()

method every time I save a number, to make sure it gets written to the disk, the LSO will always be up-to-date. Right?”

You guessed it …

### The problem

Wrong. The following scenario demonstrates it: A visitor goes to the website, makes some calculations and saves a few numbers. He then opens the pop-up version, it loads the numbers from the LSO, and he saves a few more numbers. He closes the pop-up and the LSO now contains the old numbers from the main version and the new numbers from the pop-up version. So far so good.

But now he goes to watch the latest episode of Diggnation and that’s where the problem starts. Alex and Kevin (once again) start trying to figure out how many beers they must have drank in all the Diggnation episodes. Our visitor thinks “Ah, wait a minute, I have the calculator still open. I’ll figure it out once and for all”. He clicks on the calculator tab and starts crunching the numbers. When he’s done he saves the result, so that he can email it to them, because they couldn’t figure it out. The problem is, that now the LSO contains the old numbers from the main version and the number of beers that Kevin and Alex drank – but the saved numbers from the pop-up are gone.

The reason this happens, is that once you load the LSO with the

SharedObject.getLocal("lsoID_str", "/")

method into an SWF file, the SWF file works with it’s own temporary copy of the LSO. Whatever happens with the real LSO in the meantime, it will be overwritten by the SWF’s own copy the next time

SharedObject.flush()

is called or when the SWF file flushes automatically by being closed.

### The solution

That means that you need to force the SWF to update it’s copy of the LSO before you change any information in the LSO. The intuitive way to achieve this – calling the

SharedObject.getLocal("lsoID_str", "/")

method again – doesn’t work. If the SWF already has a copy of the LSO, the

getLocal()

method will not do anything. The way you can force the SWF to load a fresh copy of the LSO however, is by first deleting the variable to which you assigned the Shared Object.

So keeping in mind, that we have to refresh the LSO every time we want to access it, or store data in it, the right code for this job might look something like this:

class SO {
public function SO() {
}
public function saveNumber(id_str:String, value:Number):Void {
}
public function returnNumber(id_str:String):Number {
return fetchedNumber;
}
}
}
}

Now, you can open multiple instances of the SWF file, save numbers in each of them and LSO will contain the saved numbers from all of them.

As you can see in the above script, the

SharedObject.getLocal("lsoID_str", "/")

method has two parameters. The first one is required and holds the name of the LSO. If an LSO with this name doesn’t exist, this method will create one. Otherwise it loads the LSO into the variable it is assigned to.

The second parameter is optional and holds the “localPath”. This is important for our example, because if “localPath” is not specified, the LSOs of the calling SWFs will be stored in a folder structure mirroring the structure on the host. That means that if one calculator is in the root directory, it’s LSO will be stored in a folder called “example-domain.com”. But if the pop-up calculator is in a subfolder of the root directory called “pop-ups”, then it’s LSO will be stored in a subfolder of the “example-domain.com” folder called “pop-ups”. The result would be, that the root calculator would not be able to read the LSO of the pop-up calculator. That is why we need to specify the second parameter. The value of “/” specifies, that the LSO is stored under “example-domain.com” to which every SWF running on that domain has access.

### Notes

This solution works reliably when the SWF files are embedded in a browser, but it works only sporadically when I open the files locally in my Flash player. I suspect this is more a problem with my system, rather then with the script, because when I open the same files locally with a browser, they work fine again.

## A small redesign

August 10th, 2008 by Marek Kyncl

Over the past month, Calculator Tab has had more visitors, than over the entire past year. This has not only made me happy, but also made me remember, that there is still a lot I’ve been wanting to change.

For one thing, I wanted to get rid of the forum, as it made any potential communication with the visitors of the site cumbersome, due to the fact that registration was required to post anything. That is why I took the forum down and installed a blog instead.

And second, I have completely rewritten the script that drives the calculator, in order to make future improvements and additions to the functionality easier to implement. As I go on writing the new version, I would like to let the users of the calculator in on the latest developments and see if they have any ideas on how I could do it better. So from now on, on the “Test Drive” page, you can see the current stage of development and if you feel like it, also influence the next version of Calculator Tab with your feedback.

© Calculator Tab 2007 - 2014