java - Apache Common Math's Fraction to Double -
java - Apache Common Math's Fraction to Double -
introduction
setcomputerizedfractionanswer
private void setcomputerizedfractionanswer(double randomdigitone, double randomdigittwo, mathematicaloperator mathematicaloperator) { this.computerizedfractionanswer = fraction(randomdigitone).add( fraction(randomdigittwo)); }
getcomputerizedfractionanswer
private fraction getcomputerizedfractionanswer() { homecoming computerizedfractionanswer; }
a double or fraction reply posted servlet , subsequently next method called:
public string validateanswer(double d) { if (getcomputerizedanswer() == d || getcomputerizedfractionanswer() == d) { homecoming "correct"; } homecoming "wrong"; }
which causes next issue:
incompatible operand types fraction , double
.
based on this , this info unclear how convert fraction type double.
question
it possible convert apache mutual math's fraction double?
per utrecht's suggestion, future references:
from api here: http://commons.apache.org/proper/commons-math/apidocs/org/apache/commons/math3/fraction/fraction.html#doublevalue%28%29, fraction
s have fellow member method doublevalue()
.
java apache math
Comments
Post a Comment