mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Dir. rearrangement according to the suggestions from Minero Aoki.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3722 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
558c428b72
commit
cff57b4a26
4 changed files with 10 additions and 9 deletions
|
@ -7,10 +7,10 @@ depend
|
||||||
extconf.rb
|
extconf.rb
|
||||||
bigdecimal_en.html
|
bigdecimal_en.html
|
||||||
bigdecimal_ja.html
|
bigdecimal_ja.html
|
||||||
lib/nlsolve.rb
|
|
||||||
lib/jacobian.rb
|
lib/jacobian.rb
|
||||||
lib/newton.rb
|
lib/newton.rb
|
||||||
lib/linear.rb
|
|
||||||
lib/ludcmp.rb
|
lib/ludcmp.rb
|
||||||
lib/pai.rb
|
|
||||||
lib/bigdecimal-rational.rb
|
lib/bigdecimal-rational.rb
|
||||||
|
sample/linear.rb
|
||||||
|
sample/nlsolve.rb
|
||||||
|
sample/pi.rb
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
#!/usr/local/bin/ruby
|
#!/usr/local/bin/ruby
|
||||||
|
|
||||||
#
|
#
|
||||||
# pai.rb
|
# pi.rb
|
||||||
#
|
#
|
||||||
|
|
||||||
require "bigdecimal"
|
require "bigdecimal"
|
||||||
#
|
#
|
||||||
# Calculates 3.1415.... using J. Machin's formula.
|
# Calculates 3.1415.... (the number of times that a circle's diameter
|
||||||
|
# will fit around the circle) using J. Machin's formula.
|
||||||
#
|
#
|
||||||
def pai(sig) # sig: Number of significant figures
|
def big_pi(sig) # sig: Number of significant figures
|
||||||
exp = -sig
|
exp = -sig
|
||||||
pi = BigDecimal::new("0")
|
pi = BigDecimal::new("0")
|
||||||
two = BigDecimal::new("2")
|
two = BigDecimal::new("2")
|
||||||
|
@ -41,9 +42,9 @@ end
|
||||||
|
|
||||||
if $0 == __FILE__
|
if $0 == __FILE__
|
||||||
if ARGV.size == 1
|
if ARGV.size == 1
|
||||||
print "PAI("+ARGV[0]+"):\n"
|
print "PI("+ARGV[0]+"):\n"
|
||||||
p pai(ARGV[0].to_i)
|
p big_pi(ARGV[0].to_i)
|
||||||
else
|
else
|
||||||
print "TRY: ruby pai.rb 1000 \n"
|
print "TRY: ruby pi.rb 1000 \n"
|
||||||
end
|
end
|
||||||
end
|
end
|
Loading…
Add table
Reference in a new issue