src/utils/image/scale-down-image.js
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 );
}
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 );
}
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 ) ; }
normalize a scale <1 to avoid some rounding issue with js numbers
normalize a scale <1 to avoid some rounding issue with js numbers