Feature #4897 ยป tau.patch
ext/bigdecimal/lib/bigdecimal/math.rb | ||
---|---|---|
7 | 7 |
# sin (x, prec) |
8 | 8 |
# cos (x, prec) |
9 | 9 |
# atan(x, prec) Note: |x|<1, x=0.9999 may not converge. |
10 |
# TAU (prec) |
|
10 | 11 |
# PI (prec) |
11 | 12 |
# E (prec) == exp(1.0,prec) |
12 | 13 |
# |
... | ... | |
144 | 145 |
y |
145 | 146 |
end |
146 | 147 |
|
148 |
# See http://tauday.com/ |
|
149 |
def TAU(prec) |
|
150 |
raise ArgumentError, "Zero or negative argument for TAU" if prec <= 0 |
|
151 |
PI(prec)*BigDecimal("2") |
|
152 |
end |
|
153 |
|
|
147 | 154 |
# Computes the value of pi to the specified number of digits of precision. |
148 | 155 |
def PI(prec) |
149 | 156 |
raise ArgumentError, "Zero or negative argument for PI" if prec <= 0 |
math.c | ||
---|---|---|
782 | 782 |
|
783 | 783 |
#ifdef M_PI |
784 | 784 |
rb_define_const(rb_mMath, "PI", DBL2NUM(M_PI)); |
785 |
rb_define_const(rb_mMath, "TAU", DBL2NUM(M_PI*2.0)); |
|
785 | 786 |
#else |
786 | 787 |
rb_define_const(rb_mMath, "PI", DBL2NUM(atan(1.0)*4.0)); |
788 |
rb_define_const(rb_mMath, "TAU", DBL2NUM(atan(1.0)*8.0)); |
|
787 | 789 |
#endif |
788 | 790 |
|
789 | 791 |
#ifdef M_E |