Post

Looking to impress your Ruby friends by calculating the largest known prime, 2**136_279_841-1? On Ruby 3.4.0-preview2 and earlier, 2**136_279_841-1 logs a warning and returns Infinity 😔. Thanks to @mametter.bsky.social, Ruby 3.4 will handle this calculation just fine! github.com/ruby/ruby/pu... 🧵

github.comDo not round `a**b` to infinity by mame · Pull Request #12033 · ruby/ruby... instead, just calculate the value unless it is too big. Also, this change raises an ArgumentError if it is expected to exceed 16 GB in a 64-bit environment. (It is possible to calculate it stra...

Knowing this, you excitedly use your ruby manager of choice to pull down ruby master (rvm install ruby-head)! You run `ruby -e "puts 2**136_279_841-1"`, and your excitement is slowly eroded. An hour into calculating, you terminate the command in frustration 😫. Is @mametter.bsky.social a LIAR?! /2

Without it, you can kiss your largest prime calculating dreams goodbye 👋 You reinstall ruby head, making sure gmp is available `brew install gmp rvm reinstall ruby-head --with-gmp-dir=$(brew --prefix gmp)` With a bit of hope in your heart, you try again: `ruby -e "puts 2**136_279_841-1"` /4

Success! @mametter.bsky.social was telling the truth! Within around 5 seconds, your terminal is filled with a beautiful output of 41,024,320 digits. Your Ruby friends cheer and carry you off on their shoulders. /5

1 repost1 like

Yes, I am trying to adopt the same mindset. Let me say here a kind of high purpose thing that I say to myself: The more we talk about Ruby in social media the higher chances that more people will find about them :)