Open Enyium opened 3 days ago
It's true that JS has that so we might as well add it. Rust has signum
It is easy to add it to your project
global MyMath {
public pure function sign(v: float) -> float {
return v < 0 ? -1 : v > 0 ? 1 : 0;
}
}
(If this was to be implemented in Slint, it could be done as a builtin macro that would be lowered in builtin_macro.rs to the equivalent of the function above)
Please add
Math.sign()
, which returns -1, 0, or 1, and should accept various data types. It is also available in browsers. I needed it with a custom component wrappingSpinBox
and changing its behavior.