| ▲ | jph an hour ago | |
Today I added Rust checked arithmetic which detects and protects math bugs such as integer addition overflow and division by zero. Rust checked arithmetic is built into Rust's standard library (std) via explicit methods on primitive integer types (such as checked_add, checked_sub, checked_mul, and checked_div), which return Option<T> and evaluate to None on overflow. There's a known tradeoff of some speed, which is fine for my purposes because I need reliability more than raw speed. I'm longtime C coder so I know how to do this in C. Rust strong types and static analysis make it so much easier to do correctly. | ||
| ▲ | Conscat 33 minutes ago | parent [-] | |
This is in the C23 standard library as well, just without nice sum types sadly. | ||