I have a couple of Java questions I was wondering if anyone could answer:
1). In this one statement, which takes the greatest common denominator and places it in the variable commom:
int common = gcd (Math.abs(numerator), denominator);
A).What is gcd? I looked it up and it's not a reserved word in the math class. In the class that this statement comes from there is no variable, object, or method named gcd. There is also no gcd variable, object, or invoked method in the client code that uses the class that this statement comes from.
B ). I know that abs is a method of the math class for the absolute value of a number(in this case the number inside the variable numerator.). And I know that when the abs method is invoked it sends the variable 'numerator' as the parameter for the data to take the absolute value of. What I don't understand is the syntax of this statement in regards to how you can take the absolute value of the variable 'denominator' haveing a variable 'numerator' inclosed in the parenthesis and simpley adding a comma to include the variable 'denominator' in the argument to be sent in the invocation of the abs method. It seems like this would be the correct syntax: int common = (Math.abs(numerator))/(Math.abs(denominator));
Can anyone explain the 'int common = gcd (Math.abs(numerator), denominator);'
statement?
Thanks,
-dman