I noticed some uses of floating point numbers. Please make sure the code you wrote does not use floats!
The code
var s = new Array(Math.floor(this.code.length*1.25));
was rewritten to:
var s = new Array((this.code.length*5) >> 2);
The following have to be rewritten... but what into?
while (!(next === Infinity || current.covers(next)))
and
assert( k <= 9007199254740991 || k >= -9007199254740991, "Internal error: current scheme cannot garantee an exact" + " representation for signed numbers greater than (2^53-1)" + " or lesser than -(2^53-1)");
There are 38 uses of Infinity in the code and 1 use of NaN... these must be removed!
I saw many asserts saying "should" when "must" is the correct term.
assert(typeof(name) === "string", "'name' argument should be a string");
It happens so often that it would be abstracted:
typeString(name, "name");
Too bad there aren't macros in JS... it would then be simply: typeString(name);
The following code is suspect:
allocator.min = function (a, accessFct) { if (accessFct === undefined) accessFct = function (x) { return x; };
var minIndex = 0; var minValue = 0; var i;
for (i=0; i < a.length; ++i) { if (accessFct(a[i]) > minValue) { minIndex = i; minValue = a[i]; } }
return { index:minIndex, value:minValue }; };
shouldn't it be:
allocator.min = function (a, accessFct) { if (accessFct === undefined) accessFct = function (x) { return x; };
var minIndex = 0; var minValue = 0; var i;
for (i=0; i < a.length; ++i) { var x = accessFct(a[i]); if (x < minValue) // NOTE: < instead of > { minIndex = i; minValue = x; // NOTE: x } }
return { index:minIndex, value:minValue }; };
Let me know if that is not correct. Has this code been tested? Moreover, it would be simpler to return the index (the value can be gotten by the client using the index). Also, is the accessFct argument really useful? It doesn't seem to be used in the code! Let's not bloat the compiler needlessly!
Marc