Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add variable-length-quantity exercise #158

Merged
merged 1 commit into from
Oct 19, 2024

Conversation

ageron
Copy link
Contributor

@ageron ageron commented Oct 15, 2024

I started by using the bitwise operators, and I got stuck with a weird bug: it turned out I was using Num.shiftRightBy instead of Num.shiftRightZfBy, therefore large U32 values would not get smaller and I'd get an infinite loop:

» 4294967295u32 |> Num.shiftRightBy 7 # NOT equivalent to // 128 for large values
4294967295 : U32

» 4294967295u32 |> Num.shiftRightZfBy 7 # always equivalent to // 128
33554431 : U32

Copy link
Contributor

@isaacvando isaacvando left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@ageron ageron merged commit c73ceef into exercism:main Oct 19, 2024
4 checks passed
@ageron ageron deleted the add-variable-length-quantity branch October 19, 2024 05:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants