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