RFR: 8376040: Add prototype "textbook complex" class

Raffaello Giulietti rgiulietti at openjdk.org
Thu Jan 22 10:47:26 UTC 2026


On Thu, 22 Jan 2026 00:35:05 GMT, Joe Darcy <darcy at openjdk.org> wrote:

> First cut at a version of complex numbers using the textbook algorithms for the arithmetic operations. This version is intended for prototyping and _not_ for production use.

src/java.base/share/classes/java/lang/ComplexTextbook.java line 195:

> 193:         } else {
> 194:             return false;
> 195:         }

Suggestion:

        return that instanceof ComplexTextbook c && real == c.real && imag == c.imag;

src/java.base/share/classes/java/lang/ComplexTextbook.java line 393:

> 391:         double b = c.imag;
> 392:         return StrictMath.hypot(a, b);
> 393:     }

Since we have `abs()`, is there a reason for not having `theta()` (or `arg()`, or whatever)?

-------------

PR Review Comment: https://git.openjdk.org/valhalla/pull/1942#discussion_r2716308811
PR Review Comment: https://git.openjdk.org/valhalla/pull/1942#discussion_r2716328488


More information about the valhalla-dev mailing list