Posts Tagged ‘number’

Windows Mobile not showing contacts

Tuesday, March 9th, 2010

I had a problem with my windows mobile phone not showing me the name of who was calling me (it only showed the number).
The deal is that I store every contact in my phone in this format:
+354 xxx xxxx
That is, first the country code, and then the phone number. When I receive a sms, my phone service provider sends the number in the same format, but when I get a phone call it omits the country code.

I couldn’t believe that WM couldn’t figure this out, so after a little searching around I found out that WM actually does figure the numbers out, but only for 8 digit local numbers. Nothing a little registry hack can’t fix.

To fix this, first download PHM Registry Editor (works for WM 6.0-6.5).
Then, edit the registry value

HKCUControlPanelPhoneCallIDMatch

to be 7 instead of the default 8.

Number Format – Thousand Separator in AS3

Wednesday, August 12th, 2009

Here’s a short number format function I wrote to easily paste in your code when needed. It’s really handy for currency formatting.
The first parameter (number:*) can be a Number, int, uint or a String class instance.
The last parameter (siStyle:Boolean) specifies whether to use the International System of Units or not. SI units have points between the thousands and a comma for the seperator (123.456.789,01). Putting siStyle as false reverses that behaviour (123,456,789.01).

It’s really ugly by design since I wanted it to be a single, tiny function. There’s loads of prettier/faster code samples out there.

function numberFormat(number:*, maxDecimals:int = 2, forceDecimals:Boolean = false, siStyle:Boolean = false):String {
    var i:int = 0, inc:Number = Math.pow(10, maxDecimals), str:String = String(Math.round(inc * Number(number))/inc);
    var hasSep:Boolean = str.indexOf(".") == -1, sep:int = hasSep ? str.length : str.indexOf(".");
    var ret:String = (hasSep && !forceDecimals ? "" : (siStyle ? "," : ".")) + str.substr(sep+1);
    if (forceDecimals) for (var j:int = 0; j <= maxDecimals - (str.length - (hasSep ? sep-1 : sep)); j++) ret += "0";
    while (i + 3 < (str.substr(0, 1) == "-" ? sep-1 : sep)) ret = (siStyle ? "." : ",") + str.substr(sep - (i += 3), 3) + ret;
    return str.substr(0, sep - i) + ret;
}