Collective Idea

Collective Idea Logo

Daniel Morrison

Fun with Unicode Math in Ruby √

By Daniel Morrison on October 11, 2012 in fun, gem, ruby, and unicode

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!

By Daniel Morrison on October 11, 2012 in fun, gem, ruby, and unicode

2 Comments

  1. Torey Heinz

    Torey Heinz October 16, 2012 http://ihswebdesign.com

    Very fun, I picked a great day to stop by the office, and to see the geekery unfold!

  2. シャネル トート

    シャネル トート April 30, 2013 http://birburim.com/profile.php?mode=viewprofile&u=426312

    シャネルは、フランスでシャネル帝国を作成したクラスと洗練された女性だった

Post a Comment

Contact Us

Find us on Google Maps
Collective Idea
44 East 8th Street, Suite 410
Holland, Michigan 49423 USA 42.790334-86.105251

Follow us on the Interwebs

We are currently available for medium and long term projects. Please get in touch if we can be of service.