Last active
June 12, 2023 19:50
-
-
Save aquaslvt/9cfe72e3fa0f64a68af792287c2e607f to your computer and use it in GitHub Desktop.
Function to calculate the integer limit of n-bit computers!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn integer_limit(bits: i128) -> i128 { | |
( 1 << bits ) - 1 | |
} |
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
I've updated it! Now it can go up to 127-bits instead of 32 ^w^