aboutsummaryrefslogtreecommitdiffstats
path: root/math.c
diff options
context:
space:
mode:
authorstomar <stomar@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-04-09 13:30:31 +0000
committerstomar <stomar@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-04-09 13:30:31 +0000
commit963829552795668dc5b04c3a40bb52161bcd1076 (patch)
treeb8a5712c7624371215fedf00fbd43771a61947ee /math.c
parent1a0dbb9eaa8b5f39025c924844c5e0e6d0822590 (diff)
downloadruby-963829552795668dc5b04c3a40bb52161bcd1076.tar.gz
math.c: improve docs for Math.sqrt
* math.c: [DOC] mention possibly surprising behavior of Math.sqrt due to floating point arithmetic; also refer to BigDecimal#sqrt. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58291 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'math.c')
-rw-r--r--math.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/math.c b/math.c
index 523937ecb3..8032e41ae3 100644
--- a/math.c
+++ b/math.c
@@ -590,6 +590,13 @@ math_log10(VALUE unused_obj, VALUE x)
* # [8, 2.82842712474619, 8.0]
* # [9, 3.0, 9.0]
* # [10, 3.16227766016838, 10.0]
+ *
+ * Note that the limited precision of floating point arithmetic
+ * might lead to surprising results:
+ *
+ * Math.sqrt(10**46).to_i #=> 99999999999999991611392 (!)
+ *
+ * See also BigDecimal#sqrt.
*/
static VALUE