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, fractions have fellow member method doublevalue().

java apache math

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -