Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

2.2 Arithmetic Operations

IntrinsicDescription
__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 = 0UINT64_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.