commaFormat#2, hiscore

I did a refactor of the commaFormat snippet, I call hiscore

public static inline function comma(num:Float)
{
    var arr = Std.string(num).split(".");
    var str = "";
    while(arr[0].length > 3) 
    {
        str = "," + arr[0].substr(-3) + str;
        arr[0] = arr[0].substr(0, arr[0].length - 3);
    }
    return arr[0] + str + if(arr.length > 1) "." + arr[1];
}

>> 10075840032
becomes >> 10,075,840,032

>> 12012301.1231
becomes >> 12,012,301.1231

version #10727, modified 2011-06-29 22:19:08 by MrCheater