improved Math.floor emulation