emory-courses / dsa-java

Data Structures and Algorithms in Java
https://emory.gitbook.io/dsa-java/
42 stars 55 forks source link

[QZ#1] add() method #27

Closed lcunild closed 4 years ago

lcunild commented 4 years ago

What is the difference between digits and n.digits in the LongInteger class? In L7 of the implementation of addSameSign() in the textbook, what is being compared by the Math.max function?

int m = Math.max(digits.length, n.digits.length);

lujiaying commented 4 years ago
public class LongInteger extends SignedNumeral<LongInteger> {
    /** The values of this integer (excluding the sign). */
    protected byte[] digits;
    ...

digits is the member field of Class LongInteger.