decToOctal method

int decToOctal()

Calculate and return the octal integer value of this integer

Implementation

int decToOctal(){
  if(this < 0){
    throw "Only positive integers can be converted into octal form using this library";
  }
  //Use a process similar to converting to hex but with base 8(octal)
  String octal = "";
  int divisionResult = this;
  do{
    octal = (divisionResult % 8).toString() + octal;
    divisionResult = (divisionResult / 8).floor();
  }while(divisionResult != 0);
  return int.parse(octal);
}