static int toFix(double val) { const fixedPoint = 20; const one = 1 << fixedPoint; return (val * one).toInt() & 0xffffffff; }