@@ -380,6 +380,15 @@ public static long multiplyHigh(long x, long y) {
380380 }
381381 }
382382
383+ /*
384+ * 向下取整除法:
385+ *
386+ * 11/ 8 = 1.375 ==> 1
387+ * -11/ 8 = -1.375 ==> -2
388+ * 11/-8 = -1.375 ==> -2
389+ * -11/-8 = 1.375 ==> 1
390+ */
391+
383392 /**
384393 * Returns the largest (closest to positive infinity)
385394 * {@code int} value that is less than or equal to the algebraic quotient.
@@ -416,7 +425,7 @@ public static long multiplyHigh(long x, long y) {
416425 * @see #floor(double)
417426 * @since 1.8
418427 */
419- // 除法,如果两数符号不同,则向下取整
428+ // 向下取整除法
420429 public static int floorDiv (int x , int y ) {
421430 int r = x / y ;
422431 // if the signs are different and modulo not zero, round down
@@ -453,7 +462,7 @@ public static int floorDiv(int x, int y) {
453462 * @see #floor(double)
454463 * @since 9
455464 */
456- // 除法,如果两数符号不同,则向下取整
465+ // 向下取整除法
457466 public static long floorDiv (long x , int y ) {
458467 return floorDiv (x , (long ) y );
459468 }
@@ -485,7 +494,7 @@ public static long floorDiv(long x, int y) {
485494 * @see #floor(double)
486495 * @since 1.8
487496 */
488- // 除法,如果两数符号不同,则向下取整
497+ // 向下取整除法
489498 public static long floorDiv (long x , long y ) {
490499 long r = x / y ;
491500 // if the signs are different and modulo not zero, round down
@@ -495,6 +504,29 @@ public static long floorDiv(long x, long y) {
495504 return r ;
496505 }
497506
507+ /*
508+ * 取模运算:
509+ *
510+ * 11 MOD 8 => 从0开始,顺时针前进11步,得到3
511+ * -11 MOD 8 => 从0开始,逆时针前进11步,得到5
512+ *
513+ * 0
514+ * 7 1
515+ * 6 2
516+ * 5 3
517+ * 4
518+ *
519+ *
520+ * 11 MOD -8 => 从0开始,顺时针前进11步,得到-5
521+ * -11 MOD -5 => 从0开始,逆时针前进11步,得到-3
522+ *
523+ * 0
524+ * -1 -7
525+ * -2 -6
526+ * -3 -5
527+ * -4
528+ */
529+
498530 /**
499531 * Returns the floor modulus of the {@code int} arguments.
500532 * <p>
0 commit comments