In search of best practice to get your facebook default profile (archive) album I came to the official facebook api wiki page. It states there that it is possible to calculate aid (album id) from your uid (user id) by simple formula:

(uid << 32) + (-3 & 0xFFFFFFFF)

Well, it may seem simple, but notice 32 bit left shifting in first part! By this operation on uid, you go far beyond integer max value and flash will not give you correct results. So how to do that?

First, I came to a BigInteger class (part of as3crypto). This class lets you operate over big integers, but when you are finished there is no way you can convert your result into a decimal string that you need for facebook call.

Then I decided to use BigDecimal class. This one let you input and output decimal strings and works perfectly for facebook purpose. To simplify it, I created static method profileAid() in FacebookUtil class:

Solution

I was not able to gather more information about BigDecimal class than this…

This is a conversion of the IBM ICU implementation of the BigDecimal for ActionScript 3, (Flash or Flex) Compiled with SDK 3.2.0. Two files are needed, BigDecimal.as and MathContext.as You can also take BigDecimalTest.as if you need some testing. Files are in the Source->Browse->Trunk. Feel free to report bugs or errors if there are any. Thanks.

…but I want to thank rouche (author’s nickname) for sharing BigDecimal class and ask him kindly to let me put this class into com.rouche.math package.