RFR: 8310033: Clarify return value of Java Time compareTo methods [v2]
Pavel Rappo
prappo at openjdk.org
Thu Jul 6 23:25:55 UTC 2023
On Tue, 20 Jun 2023 18:23:09 GMT, Roger Riggs <rriggs at openjdk.org> wrote:
> > Where did you get this idea? A "positive" means a number that is _greater_ than zero.
>
> One of my colleagues with a strong math background has corrected many of my API javadoc comments seeking to avoid any ambiguity. See reference below about positive integers.
>
> [home](https://www.math.net/) / [primary math](https://www.math.net/primary-math) / [number](https://www.math.net/number) / positive numbers Positive numbers
>
> A positive number is any number that is greater than 0. **Unlike positive integers**, which include 0 and the [natural numbers](https://www.math.net/natural-numbers), positive numbers include [fractions](https://www.math.net/fraction), [decimals](https://www.math.net/decimal), and other types of [numerals](https://www.math.net/numerals).
Late to the party. FWIW, the only way I can think of 0 as of a positive integer is when it is represented using fixed-width two's complement (e.g. Java's byte, short, int, and long). In that case, the sign bit for 0 is cleared, just like that of a positive integer and unlike that of a negative integer, assuming the same representation.
For example, the following expression will tell you if an `int i` is non-negative, i.e. zero or positive:
i >>> 31 == 0
-------------
PR Comment: https://git.openjdk.org/jdk/pull/14479#issuecomment-1624425467
More information about the core-libs-dev
mailing list