Skip to content

Instantly share code, notes, and snippets.

@kwmu4k
Last active June 12, 2023 19:50
Show Gist options
  • Save kwmu4k/9cfe72e3fa0f64a68af792287c2e607f to your computer and use it in GitHub Desktop.
Save kwmu4k/9cfe72e3fa0f64a68af792287c2e607f to your computer and use it in GitHub Desktop.
Function to calculate the integer limit of n-bit computers!
fn integer_limit(bits: i128) -> i128 {
( 1 << bits ) - 1
}
@kwmu4k
Copy link
Author

kwmu4k commented Jun 11, 2023

I've updated it! Now it can go up to 127-bits instead of 32 ^w^

@kwmu4k
Copy link
Author

kwmu4k commented Jun 11, 2023

You could also write it as fn integer_limit(bits: i128) -> i128 { 1 << bits } if you want!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment