Preface this with I am a data analyst who works primarily in SQL and some Python. My Java knowledge is from a single semester in Uni a decade ago. I have been tasked with updating a process that has largely been untouched since it was written in 2002. It used some very convoluted SQL to pull from source DB, probably written by a java person, and then several java functions to manipulate the data to the desired report outcome.
I have worked through 3 of the five functions and recreated/refined the process, but am stuck on several things.
This code here:
public void calculateCorrectionFactor(int roundingSecs)
throws CtFatalException
{
if (roundingSecs < 1)
{
throw new CtFatalException("roundingSecs must be > 0");
}
double sign = 1d;
if (this.modalDriftSecs < 0)
{
sign = -1d;
}
double dividend = this.modalDriftSecs*sign/roundingSecs;
String str = Double.toString(dividend+0.5d);
int indexOfDecimal = str.indexOf('.');
String intStr = str.substring(0,indexOfDecimal);
int parsedInt = Integer.parseInt(intStr);
Double doubleSign = new Double(sign);
this.calculatedCorrectionFactor = doubleSign.intValue()*parsedInt*roundingSecs ;}
The gist I understand is this calculation modalDriftSecs*sign/roundingSecs is the main output, but what is the -1d and 1d for sign? A double is purely numerical, isn't it?