Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MyBigInteger base = new MyBigInteger(10);
- base.coefficients.add(newBase);
- MyBigInteger oldBase = new MyBigInteger(this.base);
- oldBase.coefficients.add(this.base);
- //System.out.println(base);
- // ADD YOUR CODE BELOW HERE
- MyBigInteger zero = new MyBigInteger(0, 10);
- //System.out.println(zero);
- if(this.base!=10) { // Change base to 10
- result.base=this.base;
- int n = this.getCoefficients().size(); // Length of this
- MyBigInteger temp = new MyBigInteger(this.base); // Temporary BigInt
- for(int i=0; i<n; i++) {
- temp.coefficients.add(this.getCoefficients().get(i));
- // Adds coefficients of this to temp
- System.out.println(temp+" - "+temp.timesBaseToThePower(i));
- for(int j=0; j<=i; j++) {
- result=result.plus(temp.times(oldBase));
- }
- //result=result.plus(temp.timesBaseToThePower(i));
- //System.out.println(result);
- temp.coefficients.clear();
- }
- result.base = 10;
- //System.out.println(this+" In Base 10 "+result);
- this.base = 10;
- this.coefficients=result.getCoefficients();
- result.coefficients.clear();
- result.base=newBase;
- }
- while(this.compareTo(zero)!=0) { // change from 10 to new base
- result.coefficients.add(this.mod(base).getCoefficients().get(0));
- // Adds number % base to results
- this.coefficients = this.dividedBy(base).coefficients;
- // Number = Number / Base
- if(this.compareTo(empty)==0){
- //System.out.println("Empty");
- break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement