Close
Glad You're Ready. Let's Get Started!

Let us know how we can contact you.

Thank you!

We'll respond shortly.

LABS
NYC Standup Roundup – Week of 4/12

Help

Does anybody have any good techniques for dealing with STDOUT/STDERR and exception handling when shelling out in Ruby on Windows?

Nobody did. Do you? Please share in the comments.

Interesting

A pair ran system updates on their Snow Leopard box which caused bunch of test failures in their project. Most of the failures were occurring around the parts of the application that used BigDecimal. After digging they found:

     >> BigDecimal.new("1.01").to_f
     => 1.1

Oops! Looks like Apple shipped Ruby 1.8.7 p173 with a recent update. p173 has a bug that some dude introduced into BigDecimal. The fix was to update to p174 which was released quickly after this was discovered.

While on the subject, BigDecimal is kind of a drag. Its #inspect output is inhumane and new’ing up BigDecimal objects requires an ugly call to its constructor. A Pivot recommended using the undocumented bigdecimal/util which adds a convenience method to Float for creating new BigDecimals:

    >> require 'bigdecimal/util'
    >> 3.14159265.to_d
    => #<BigDecimal:10056bea8,'0.314159265E1',12(16)>

And a nickel’s worth of free advice?

    >> BigDecimal.send :alias_method, :inspect, :to_s
    >> 98.6.to_d
    => 0.986E2

Unless you prefer:

    #<BigDecimal:101137c78,'0.986E2',8(8)>

Comments
  1. Ben Pickles says:

    Thanks for the `BigDecimal` tips, really useful. However although `to_d` works for me with 1.8.7 p173 it’s failing with “undefined method `BigDecimal’ for 3.14159265:Float” with 1.8.7 p249 and 1.9.2. Has it been removed?

    Ben

  2. John Pignata says:

    Hi Ben — That smells like a bug. We’re using it with p174. From that exception it just seems broken. You may want to poke ruby-core and ask what’s up.

Post a Comment

Your Information (Name required. Email address will not be displayed with comment.)

* Copy This Password *

* Type Or Paste Password Here *