2.2 Arithmetic Operations
| Intrinsic | Description |
|---|---|
__signed_shr__(val bits) | Arithmetic (signed) right shift; fills vacated bits with the sign bit |
__unsigned_idiv__(lhs rhs) | Unsigned 64-bit division (RISC-V divu / remu semantics) |
__unsigned_mod__(lhs rhs) | Unsigned 64-bit remainder |
| Case | __unsigned_idiv__(a, b) | __unsigned_mod__(a, b) |
|---|---|---|
b = 0 | UINT64_MAX (0xFFFF_FFFF_FFFF_FFFF) | a |
Divide-by-zero quotients use the same bit pattern as signed -1; only the interpretation differs.
| __unsigned_lt__(lhs rhs) | Unsigned less-than comparison |
| __unsigned_gt__(lhs rhs) | Unsigned greater-than comparison |
| __unsigned_lte__(lhs rhs) | Unsigned less-than-or-equal comparison |
| __unsigned_gte__(lhs rhs) | Unsigned greater-than-or-equal comparison |
Use __signed_shr__ when you need sign-preserving right shift. The >> operator always performs unsigned (logical) shift. Likewise, //, %, and relational operators remain signed by default; use the unsigned intrinsics when you need unsigned interpretation.