2 ms·
I love the syntax for checked math. a + b for wrap around, a +? b to raise an exception on under/overflow, and a +~ b for maximum performance, leaving behavior
by wongarsu 1y ago
I love the syntax for checked math. a + b for wrap around, a +? b to raise an exception on under/overflow, and a +~ b for maximum performance, leaving behavior on under/overflow undefined (including floats having undefined behavior on +-Inf and NaN).
Compared to e.g. Rust (one of the better modern examples of easy rigorous math) I really like how concise they are. What I'm missing are saturating operations. I know some people find them useless, and through a "perfect results" lens they are, but they still give you the closest representable number. And they are often intuitive for humans since that's how most analog instruments work
- renox 1y agoIt's interesting that Rust and Pony have différent default for addition.