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... 🧵
Post
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
As it turns out, there is critically important library you need for accelerating "Bignum" calculations: GMP, the GNU Multiple Precision Arithmetic Library. It's even specifically mentioned in the CRuby guide to building ruby: docs.ruby-lang.org/en/master/co... /3
1 repost1 like
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
This was all inspired by @matz.bsky.social's keynote at #RubyConf - where he mentioned that Ruby 3.4 can now calculate the largest known prime. For fun, I tried it on my mac and just let it keep running - 2 hours later, it was still running! I'd never heard of GMP, but now I know! gmplib.org /🧵