Ad
  • Custom User Avatar

    What exactly is the suggestion here? What needs to be changed in the code of the kata?

  • Custom User Avatar

    RISC-V srli Implementation Issue: It turn out not to be logical shift

    If you're getting incorrect results with large inputs (especially numbers > 2^31), check your srli (Shift Right Logical Immediate) results. Some implementations might incorrectly perform arithmetic right shift instead of logical right shift.
    Example of the issue:
    Input: 3435973832

    Correct srli result (input >> 3): 429496729
    Incorrect result seen: 4187593113 (arithmetic shift behavior)

    Brute Solution: Mask the result after shift to ensure upper bits are zero:

    This issue particularly affects calculations involving division by powers of 2 using right shifts on large unsigned numbers.