On Mon, 2 Feb 2026 21:35:03 GMT, Chen Liang <[email protected]> wrote:

> Good that we are encapsulating degree with methods; might add a comment to 
> indicate this intention, like no direct access for lazy fields.
> 
> Also, I noted we use (`this.`)`coeffs.length` a lot. How is it distinct from 
> `deg()`? Hope we can clarify on that as well.
> 
> Otherwise, looks nice in concept.

The notion of "degree" is a polynomial concept while the length of the backing 
array is an implementation artifact. With this data structure; degree is 
_almost_ length - 1. The exception is a zero polynomial, which needs special 
handling somehow since its degree is defined to not be 0 -- as would be the 
case for any other constant polynomial -- but -1 (or sometimes -infinity).

Writing this comment, this might tip my scales to internally use an empty array 
to special case zero. That way, the degree would be one less than the length is 
all cases.

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

PR Comment: https://git.openjdk.org/valhalla/pull/2004#issuecomment-3837572397

Reply via email to