@@ -534,7 +534,10 @@ public static long gcd(long a, long b) {
534
534
* Returns the sum of {@code a} and {@code b}, provided it does not overflow.
535
535
*
536
536
* <p><b>Note:</b> this method is now unnecessary and should be treated as deprecated; use {@link
537
- * Math#addExact(long, long)} instead.
537
+ * Math#addExact(long, long)} instead. Note that if both arguments are {@code int} values, writing
538
+ * {@code Math.addExact(a, b)} will call the {@link Math#addExact(int, int)} overload, not {@link
539
+ * Math#addExact(long, long)}. Also note that adding two {@code int} values can <b>never</b>
540
+ * overflow a {@code long}, so you can just write {@code (long) a + b}.
538
541
*
539
542
* @throws ArithmeticException if {@code a + b} overflows in signed {@code long} arithmetic
540
543
*/
@@ -547,7 +550,11 @@ public static long checkedAdd(long a, long b) {
547
550
* Returns the difference of {@code a} and {@code b}, provided it does not overflow.
548
551
*
549
552
* <p><b>Note:</b> this method is now unnecessary and should be treated as deprecated; use {@link
550
- * Math#subtractExact(long, long)} instead.
553
+ * Math#subtractExact(long, long)} instead. Note that if both arguments are {@code int} values,
554
+ * writing {@code Math.subtractExact(a, b)} will call the {@link Math#subtractExact(int, int)}
555
+ * overload, not {@link Math#subtractExact(long, long)}. Also note that subtracting two {@code
556
+ * int} values can <b>never</b> overflow a {@code long}, so you can just write {@code (long) a -
557
+ * b}.
551
558
*
552
559
* @throws ArithmeticException if {@code a - b} overflows in signed {@code long} arithmetic
553
560
*/
@@ -560,7 +567,11 @@ public static long checkedSubtract(long a, long b) {
560
567
* Returns the product of {@code a} and {@code b}, provided it does not overflow.
561
568
*
562
569
* <p><b>Note:</b> this method is now unnecessary and should be treated as deprecated; use {@link
563
- * Math#multiplyExact(long, long)} instead.
570
+ * Math#multiplyExact(long, long)} instead. Note that if both arguments are {@code int} values,
571
+ * writing {@code Math.multiplyExact(a, b)} will call the {@link Math#multiplyExact(int, int)}
572
+ * overload, not {@link Math#multiplyExact(long, long)}. Also note that multiplying two {@code
573
+ * int} values can <b>never</b> overflow a {@code long}, so you can just write {@code (long) a *
574
+ * b}.
564
575
*
565
576
* @throws ArithmeticException if {@code a * b} overflows in signed {@code long} arithmetic
566
577
*/
0 commit comments