mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 18:58:36 +00:00
C++: fix mod
with negative number again
`mod(-42, 2)` would return 2 instead of 0
This commit is contained in:
parent
18b05d0734
commit
3621fbcbd3
2 changed files with 8 additions and 2 deletions
|
@ -3483,7 +3483,7 @@ fn compile_builtin_function_call(
|
|||
}
|
||||
BuiltinFunction::Mod => {
|
||||
ctx.generator_state.conditional_includes.cmath.set(true);
|
||||
format!("([](float a, float b) {{ return a >= 0 ? std::fmod(a, b) : std::fmod(a, b) + std::abs(b); }})({},{})", a.next().unwrap(), a.next().unwrap())
|
||||
format!("([](float a, float b) {{ auto r = std::fmod(a, b); return r >= 0 ? r : r + std::abs(b); }})({},{})", a.next().unwrap(), a.next().unwrap())
|
||||
}
|
||||
BuiltinFunction::Round => {
|
||||
ctx.generator_state.conditional_includes.cmath.set(true);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue