[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ruby-talk
Subject:    Re: Exact (LISP-ish) calculations in Ruby?
From:       Aaron Patterson <aaron () tenderlovemaking ! com>
Date:       2009-11-18 17:15:51
Message-ID: 20091118171525.GA27720 () ypctb06029 ! yellowpages ! local
[Download RAW message or body]

On Wed, Nov 18, 2009 at 11:35:36PM +0900, Aldric Giacomoni wrote:
> Has anyone written a gem for exact calculations? The kind one would find
> on a LISP REPL, or when using your average HP scientific calculator?
> >> 3 / 4
> => 3/4
> >> 3 / 6
> => 1/2
> >> sqrt(2)
> => sqrt(2)
> >> sqrt(4)
> >> 2
> 
> I couldn't find anything on gemcutter or rubyforge, but maybe I missed
> it..
> I don't ask because I need it.. I ask because of an idealistic desire
> for exact calculations :)

How about the Rational class in stdlib?

  http://ruby-doc.org/stdlib/libdoc/rational/rdoc/index.html

-- 
Aaron Patterson
http://tenderlovemaking.com/

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic