Monday, July 2, 2012

Why a/b*c is not equal to a*c/b

For some it may be obvious, but it took me a while to understand a problem. So I thought that multiplication and division are alternating. Maybe for Mathematics but not for computer. Let's have a look at example:



var a:Number = 1400;
var b:Number = 10000;
var c:Number = 100;


trace(a/b*c);
trace(a*c/b);

From mathematical point of view those results should be equal. But here what flash returns:


14.000000000000002
14

Of course simple round, toFixed() or other operation will mask this problem but it's not a good solution.
Type Number is double-precision with 64bits representation. Division with result different then integer is represents by number with 16 digits of precision.


Monday, January 30, 2012

unable to open 'C:\... libs\player\9.0\playerglobal.swc' - Solution

If you ever see an error unable to open 'C:\... libs\player\9.0\playerglobal.swc' in your Problems tab maybe below is a solution for you.
I found this situation while importing some projects. I'm still using flex builder 3 while project has been imported from flash builder 4 where was SDK 4.1. I'm not sure why, but somehow during import some old sdk was used as default. Of course I switched it to the good one but then this error occurred.

The fastest way is to set, and later unset requiring a flash version in compiler tab in project properties.
All you have to do is to check 'Generate HTML wrapper file.
Check Require Flash Player version ans set at least major number to 10.
Press Apply.
Uncheck 'Generate ...' so it will turn off.
It's done!