Fix floating point exception in emulator