ruby-changes:19835
From: drbrain <ko1@a...>
Date: Wed, 1 Jun 2011 09:26:33 +0900 (JST)
Subject: [ruby-changes:19835] drbrain:r31881 (trunk): * lib/mathn.rb: Improve documentation and attach it to Numeric.
drbrain 2011-06-01 09:26:27 +0900 (Wed, 01 Jun 2011) New Revision: 31881 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=31881 Log: * lib/mathn.rb: Improve documentation and attach it to Numeric. Modified from patch by Anil V. [Ruby 1.9 - Bug #4762] Modified files: trunk/ChangeLog trunk/lib/mathn.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 31880) +++ ChangeLog (revision 31881) @@ -1,3 +1,8 @@ +Wed Jun 1 09:26:05 2011 Eric Hodel <drbrain@s...> + + * lib/mathn.rb: Improve documentation and attach it to Numeric. + Modified from patch by Anil V. [Ruby 1.9 - Bug #4762] + Wed Jun 1 09:21:30 2011 Eric Hodel <drbrain@s...> * lib/prime.rb: Indent examples enough to appear as code sections. Index: lib/mathn.rb =================================================================== --- lib/mathn.rb (revision 31880) +++ lib/mathn.rb (revision 31881) @@ -1,43 +1,45 @@ +#-- +# $Release Version: 0.5 $ +# $Revision: 1.1.1.1.4.1 $ + ## # = mathn # -# mathn is a library for changing the way Ruby does math. If you need +# mathn is a library for changing the way Ruby does math. If you need # more precise rounding with multiple division or exponentiation -# operations, then mathn is the right tool. It makes sense to use this -# library if you can use it's late rounding. Mathn does not convert -# Fixnums into Floats as long as you do not convert it yourself. -# Instead of using Float as intermediate value it use Rational as -# value representation. +# operations, then mathn is the right tool. # -# Example Fixnum with intermediate Float: +# Without mathn: # -# 20 / 9 * 3 * 14 / 7 * 3 / 2 # => 18 +# 3 / 2 => 1 # Integer # -# Example: using mathn Fixnum/Rational: +# With mathn: # -# require 'mathn' -# 20 / 9 * 3 * 14 / 7 * 3 / 2 # => 20 +# 3 / 2 => 3/2 # Rational # -# == Usage +# mathn features late rounding and lacks truncation of intermediate results: # -# To start using this library, simply: +# Without mathn: # -# require "mathn" +# 20 / 9 * 3 * 14 / 7 * 3 / 2 # => 18 # -# This will change the way division works for Fixnums, specifically +# With mathn: # -# 3 / 2 +# 20 / 9 * 3 * 14 / 7 * 3 / 2 # => 20 # -# will return +Rational+ (3/2) instead of the usual +Fixnum+ 1. # +# When you require 'mathn' the libraries for Prime, CMath, Matrix and Vector +# are also loaded. +# # == Copyright # -# Author: Keiju ISHITSUKA(SHL Japan Inc.) -# +# Author: Keiju ISHITSUKA (SHL Japan Inc.) #-- -# $Release Version: 0.5 $ -# $Revision: 1.1.1.1.4.1 $ +# class Numeric follows to make this documentation findable in a reasonable +# location +class Numeric; end + require "cmath.rb" require "matrix.rb" require "prime.rb" -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/