зеркало из https://github.com/github/ruby.git
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:
Родитель
558c428b72
Коммит
cff57b4a26
|
@ -7,10 +7,10 @@ depend
|
|||
extconf.rb
|
||||
bigdecimal_en.html
|
||||
bigdecimal_ja.html
|
||||
lib/nlsolve.rb
|
||||
lib/jacobian.rb
|
||||
lib/newton.rb
|
||||
lib/linear.rb
|
||||
lib/ludcmp.rb
|
||||
lib/pai.rb
|
||||
lib/bigdecimal-rational.rb
|
||||
sample/linear.rb
|
||||
sample/nlsolve.rb
|
||||
sample/pi.rb
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
#!/usr/local/bin/ruby
|
||||
|
||||
#
|
||||
# pai.rb
|
||||
# pi.rb
|
||||
#
|
||||
|
||||
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
|
||||
pi = BigDecimal::new("0")
|
||||
two = BigDecimal::new("2")
|
||||
|
@ -41,9 +42,9 @@ end
|
|||
|
||||
if $0 == __FILE__
|
||||
if ARGV.size == 1
|
||||
print "PAI("+ARGV[0]+"):\n"
|
||||
p pai(ARGV[0].to_i)
|
||||
print "PI("+ARGV[0]+"):\n"
|
||||
p big_pi(ARGV[0].to_i)
|
||||
else
|
||||
print "TRY: ruby pai.rb 1000 \n"
|
||||
print "TRY: ruby pi.rb 1000 \n"
|
||||
end
|
||||
end
|
Загрузка…
Ссылка в новой задаче