Skip to content

Commit 7789aac

Browse files
BurdetteLamarpeterzhu2118
authored andcommitted
[DOC] Tweaks for Integer#**
1 parent b47b37c commit 7789aac

File tree

1 file changed

+42
-11
lines changed

1 file changed

+42
-11
lines changed

numeric.c

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4592,17 +4592,48 @@ fix_pow(VALUE x, VALUE y)
45924592

45934593
/*
45944594
* call-seq:
4595-
* self ** numeric -> numeric_result
4596-
*
4597-
* Raises +self+ to the power of +numeric+:
4598-
*
4599-
* 2 ** 3 # => 8
4600-
* 2 ** -3 # => (1/8)
4601-
* -2 ** 3 # => -8
4602-
* -2 ** -3 # => (-1/8)
4603-
* 2 ** 3.3 # => 9.849155306759329
4604-
* 2 ** Rational(3, 1) # => (8/1)
4605-
* 2 ** Complex(3, 0) # => (8+0i)
4595+
* self ** exponent -> numeric
4596+
*
4597+
* Returns the value of base +self+ raised to the power +exponent+;
4598+
* see {Exponentiation}[https://en.wikipedia.org/wiki/Exponentiation]:
4599+
*
4600+
* # Result for non-negative Integer exponent is Integer.
4601+
* 2 ** 0 # => 1
4602+
* 2 ** 1 # => 2
4603+
* 2 ** 2 # => 4
4604+
* 2 ** 3 # => 8
4605+
* -2 ** 3 # => -8
4606+
* # Result for negative Integer exponent is Rational, not Float.
4607+
* 2 ** -3 # => (1/8)
4608+
* -2 ** -3 # => (-1/8)
4609+
*
4610+
* # Result for Float exponent is Float.
4611+
* 2 ** 0.0 # => 1.0
4612+
* 2 ** 1.0 # => 2.0
4613+
* 2 ** 2.0 # => 4.0
4614+
* 2 ** 3.0 # => 8.0
4615+
* -2 ** 3.0 # => -8.0
4616+
* 2 ** -3.0 # => 0.125
4617+
* -2 ** -3.0 # => -0.125
4618+
*
4619+
* # Result for non-negative Complex exponent is Complex with Integer parts.
4620+
* 2 ** Complex(0, 0) # => (1+0i)
4621+
* 2 ** Complex(1, 0) # => (2+0i)
4622+
* 2 ** Complex(2, 0) # => (4+0i)
4623+
* 2 ** Complex(3, 0) # => (8+0i)
4624+
* -2 ** Complex(3, 0) # => (-8+0i)
4625+
* # Result for negative Complex exponent is Complex with Rational parts.
4626+
* 2 ** Complex(-3, 0) # => ((1/8)+(0/1)*i)
4627+
* -2 ** Complex(-3, 0) # => ((-1/8)+(0/1)*i)
4628+
*
4629+
* # Result for Rational exponent is Rational.
4630+
* 2 ** Rational(0, 1) # => (1/1)
4631+
* 2 ** Rational(1, 1) # => (2/1)
4632+
* 2 ** Rational(2, 1) # => (4/1)
4633+
* 2 ** Rational(3, 1) # => (8/1)
4634+
* -2 ** Rational(3, 1) # => (-8/1)
4635+
* 2 ** Rational(-3, 1) # => (1/8)
4636+
* -2 ** Rational(-3, 1) # => (-1/8)
46064637
*
46074638
*/
46084639
VALUE

0 commit comments

Comments
 (0)