Re:The C++ Iceberg
by planede on Wednesday May 08, 2024 @05:39AM
(#40296041)
How does arithmetic work with NonZeroI16 and remain efficient? What's the codegen of adding/subtracting two NonZeroI16 values?
[ Parent
| on HN ]
Re:The C++ Iceberg
by tialaramex on Wednesday May 08, 2024 @06:48AM
(#40296476)
Whether we can efficiently do other arithmetic depends on what we're doing, but that's not necessarily on our critical path even if the division is.
They don't support general arithmetic. They do have member functions for abs, multiplication, negation and power operations, but they are all checked/saturating if they can result in 0.
If you want to do actual arithmetic, you have to get the internal i16, perform the arithmetic, then rewrap it.