From fe31559af818bcc1771b1a2eafc7f3aa1cac3f75 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 11 Apr 2026 22:45:57 +0300 Subject: feat: implement binary exponentiation with ** operator - Add PowInt(int) method to Number interface - Implement binary exponentiation for Float and Rat types - Add FastPower operator to handle ** operator - Register ** operator in NewOperatorRegistry - Add unit tests for PowInt (basic, large, negative exponents) - Add integration tests for ** operator (CLI and stdin) - Update README.md with ** operator documentation --- README.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'README.md') diff --git a/README.md b/README.md index ef97fdd..b722ddc 100644 --- a/README.md +++ b/README.md @@ -83,16 +83,27 @@ gt '5 6 *' # 5 * 6 = 30 gt '20 4 /' # 20 / 4 = 5 # → 5 -gt '2 3 ^' # 2^3 = 8 +gt '2 3 ^' # 2^3 = 8 (floating-point power) # → 8 gt '2 10 **' # 2^10 = 1024 (Fast binary exponentiation) # → 1024 +gt '2 -3 **' # 2^(-3) = 0.125 (negative integer exponent) +# → 0.125 + +gt '5 0 **' # 5^0 = 1 (zero exponent) +# → 1 + +gt '10 100 **' # 10^100 (very large exponent - efficient) +# → 1e+100 + gt '10 3 %' # 10 % 3 = 1 (modulo) # → 1 ``` +**Note:** The `**` operator uses binary exponentiation (exponentiation by squaring), which is more efficient than the general `^` operator for large integer exponents. It only works with integer exponents. + #### Expression Chaining ```bash -- cgit v1.2.3