java - Divide values from a class extending number -


i have class extends number.

public class quantity extends number{  } 

and class as,

public class test{  quantity tkphmaxvalue; quantity tkphvalue;   public test(quantity tkphvalue, quantity maxvalue){     this.tkphvalue= tkphvalue;     this.maxvalue= maxvalue;  }    public quantity gettkphvalue() {     return tkphvalue; }  public void settkphvalue(quantity tkphvalue) {     this.tkphvalue = tkphvalue; }    public quantity gettkphmaxvalue() {     return tkphmaxvalue; }  public void settkphmaxvalue(quantity maxvalue) {     this.tkphmaxvalue = maxvalue; }  } 

i need divide ((gettkphvalue()/gettkphmaxvalue())*100) percentage value. how can convert quantity object number?

try this:

((gettkphvalue().doublevalue()/gettkphmaxvalue().doublevalue())*100) 

before do, make sure tkphmaxvalue , tkphvalue not null.


Comments

Popular posts from this blog

javascript - IndexedDB error: Uncaught DataCloneError: Failed to execute 'put' on 'IDBObjectStore': An object could not be cloned -

amazon web services - When using Cognito credentials with AWS in a browser (javascript), keep getting "missing credentials" error -

c# - How to set the datatextfield value instead of the value on a drop down list? -