Skip to content

Commit 07696bc

Browse files
authored
Update example calculation result in BigMath document (#428)
1 parent 44a2bb6 commit 07696bc

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

lib/bigdecimal/math.rb

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
#
2626
# include BigMath
2727
#
28-
# a = BigDecimal((PI(100)/2).to_s)
29-
# puts sin(a,100) # => 0.99999999999999999999......e0
28+
# a = BigDecimal((PI(49)/2).to_s)
29+
# puts sin(a,100) # => 0.9999999999...9999999986e0
3030
#
3131
module BigMath
3232
module_function
@@ -37,8 +37,8 @@ module BigMath
3737
# Computes the square root of +decimal+ to the specified number of digits of
3838
# precision, +numeric+.
3939
#
40-
# BigMath.sqrt(BigDecimal('2'), 16).to_s
41-
# #=> "0.1414213562373095048801688724e1"
40+
# BigMath.sqrt(BigDecimal('2'), 32).to_s
41+
# #=> "0.14142135623730950488016887242097e1"
4242
#
4343
def sqrt(x, prec)
4444
BigDecimal::Internal.validate_prec(prec, :sqrt)
@@ -81,8 +81,8 @@ def sqrt(x, prec)
8181
#
8282
# If +decimal+ is Infinity or NaN, returns NaN.
8383
#
84-
# BigMath.sin(BigMath.PI(5)/4, 5).to_s
85-
# #=> "0.70710678118654752440082036563292800375e0"
84+
# BigMath.sin(BigMath.PI(5)/4, 32).to_s
85+
# #=> "0.70710807985947359435812921837984e0"
8686
#
8787
def sin(x, prec)
8888
BigDecimal::Internal.validate_prec(prec, :sin)
@@ -118,8 +118,8 @@ def sin(x, prec)
118118
#
119119
# If +decimal+ is Infinity or NaN, returns NaN.
120120
#
121-
# BigMath.cos(BigMath.PI(4), 16).to_s
122-
# #=> "-0.999999999999999999999999999999856613163740061349e0"
121+
# BigMath.cos(BigMath.PI(16), 32).to_s
122+
# #=> "-0.99999999999999999999999999999997e0"
123123
#
124124
def cos(x, prec)
125125
BigDecimal::Internal.validate_prec(prec, :cos)
@@ -140,8 +140,8 @@ def cos(x, prec)
140140
# BigMath.tan(BigDecimal("0.0"), 4).to_s
141141
# #=> "0.0"
142142
#
143-
# BigMath.tan(BigMath.PI(4) / 4, 4).to_s
144-
# #=> "0.99999999999999999999419869652481995799388629632650769e0"
143+
# BigMath.tan(BigMath.PI(24) / 4, 32).to_s
144+
# #=> "0.99999999999999999999999830836025e0"
145145
#
146146
def tan(x, prec)
147147
BigDecimal::Internal.validate_prec(prec, :tan)
@@ -156,8 +156,8 @@ def tan(x, prec)
156156
#
157157
# If +decimal+ is NaN, returns NaN.
158158
#
159-
# BigMath.atan(BigDecimal('-1'), 16).to_s
160-
# #=> "-0.785398163397448309615660845819878471907514682065e0"
159+
# BigMath.atan(BigDecimal('-1'), 32).to_s
160+
# #=> "-0.78539816339744830961566084581988e0"
161161
#
162162
def atan(x, prec)
163163
BigDecimal::Internal.validate_prec(prec, :atan)
@@ -194,8 +194,8 @@ def atan(x, prec)
194194
# Computes the value of pi to the specified number of digits of precision,
195195
# +numeric+.
196196
#
197-
# BigMath.PI(10).to_s
198-
# #=> "0.3141592653589793238462643388813853786957412e1"
197+
# BigMath.PI(32).to_s
198+
# #=> "0.31415926535897932384626433832795e1"
199199
#
200200
def PI(prec)
201201
BigDecimal::Internal.validate_prec(prec, :PI)
@@ -239,8 +239,8 @@ def PI(prec)
239239
# Computes e (the base of natural logarithms) to the specified number of
240240
# digits of precision, +numeric+.
241241
#
242-
# BigMath.E(10).to_s
243-
# #=> "0.271828182845904523536028752390026306410273e1"
242+
# BigMath.E(32).to_s
243+
# #=> "0.27182818284590452353602874713527e1"
244244
#
245245
def E(prec)
246246
BigDecimal::Internal.validate_prec(prec, :E)

0 commit comments

Comments
 (0)