summaryrefslogtreecommitdiff
path: root/complex.c
diff options
context:
space:
mode:
authorBurdette Lamar <BurdetteLamar@Yahoo.com>2025-12-02 20:39:25 -0600
committerGitHub <noreply@github.com>2025-12-02 21:39:25 -0500
commitb2f110651c0ab1c3991dd89dc2529a6f21e17170 (patch)
tree9aeb9fb8fe688f1c2e9a4a6ac5a5aa8bc69aa7bc /complex.c
parentf4466ec8cb1e11192fd9e967bf564c2b4c37d55d (diff)
[DOC] Harmonize #+ methods
Diffstat (limited to 'complex.c')
-rw-r--r--complex.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/complex.c b/complex.c
index d69b0a6581..12dec4d23b 100644
--- a/complex.c
+++ b/complex.c
@@ -816,17 +816,26 @@ rb_complex_uminus(VALUE self)
}
/*
- * call-seq:
- * complex + numeric -> new_complex
+ * call-seq:
+ * self + other -> numeric
+ *
+ * Returns the sum of +self+ and +other+:
+ *
+ * Complex(1, 2) + 0 # => (1+2i)
+ * Complex(1, 2) + 1 # => (2+2i)
+ * Complex(1, 2) + -1 # => (0+2i)
+ *
+ * Complex(1, 2) + 1.0 # => (2.0+2i)
+ *
+ * Complex(1, 2) + Complex(2, 1) # => (3+3i)
+ * Complex(1, 2) + Complex(2.0, 1.0) # => (3.0+3.0i)
*
- * Returns the sum of +self+ and +numeric+:
+ * Complex(1, 2) + Rational(1, 1) # => ((2/1)+2i)
+ * Complex(1, 2) + Rational(1, 2) # => ((3/2)+2i)
*
- * Complex.rect(2, 3) + Complex.rect(2, 3) # => (4+6i)
- * Complex.rect(900) + Complex.rect(1) # => (901+0i)
- * Complex.rect(-2, 9) + Complex.rect(-9, 2) # => (-11+11i)
- * Complex.rect(9, 8) + 4 # => (13+8i)
- * Complex.rect(20, 9) + 9.8 # => (29.8+9i)
+ * For a computation involving Floats, the result may be inexact (see Float#+):
*
+ * Complex(1, 2) + 3.14 # => (4.140000000000001+2i)
*/
VALUE
rb_complex_plus(VALUE self, VALUE other)