code: function normaliseScale(s) {
    if (s>1) throw('s must be <1');
    s = 0 | (1/s);
    var l = log2(s);
    var mask = 1 << l;
    var accuracy = 4;
    while(accuracy && l) { l--; mask |= 1<<l; accuracy--; }
    return 1 / ( s & mask );
  }
docs: normalize a scale <1 to avoid some rounding issue with js numbers