Fun with Unicode Math in Ruby √

So we started having some fun with Ruby yesterday:

# Get the square root of 5
√ 5  #  => 2.23606797749979 

# or see if infinity + 1 is still in the infinite range
(-∞..∞).cover? ∞ + 1  # => true

# or get the sine of pi / 2
∿ π/2  # => 1.0

# or do math with fractions
⅞ * ⅔ # => 0.5833333333333333

Now you can do all of this and more with the unicode_math gem!

Simply install the gem and you’re off and running.

gem install unicode_math

Check out the source code on GitHub. We’d love to see your ideas for more fun, so get those pull requests coming!

Finally, why would we do this‽ Because it was fun, and Ruby has great support for unicode. Enjoy!

Photo of Daniel Morrison

Among colleagues, Daniel is known for rambling about algorithm design or obscure academic terms, which he blames on his classical training in Computer Science. Among clients, Daniel is known for being honest and direct when trying to get clients to focus on value and efficiency, which he blames on his unwavering quest for…value and efficiency.

Daniel founded Collective Idea in 2005 to put a name to his growing and already full-time freelance work. He works hard writing code, teaching, mentoring, and speaking about the company’s processes and tools.


Post a Comment

(optional — will be included as a link.)
  1. Very fun, I picked a great day to stop by the office, and to see the geekery unfold!

    October 16, 2012 at 16:39 PM
  2. シャネルは、フランスでシャネル帝国を作成したクラスと洗練された女性だった

    May 01, 2013 at 1:33 AM