use more correct logic for mod

This commit is contained in:
Emil Gardström
2024-04-29 13:23:28 +02:00
parent 078e2bb05a
commit a6af244080

View File

@@ -1745,7 +1745,11 @@ impl IC {
} = reg.as_register(this, inst, 1)?;
let a = a.as_value(this, inst, 2)?;
let b = b.as_value(this, inst, 1)?;
this.set_register(indirection, target, ((a % b) + b) % b)?;
let mut m = (a % b);
if m < 0.0 {
m += b;
}
this.set_register(indirection, target, m)?;
Ok(())
}
oprs => Err(ICError::mismatch_operands(oprs.len(), 3)),