Il metodo arrotonda all'intero successivo.codice:public void setInteroSup(double z){ String Ris = new String(""); //double z = 501.8; -> oki 502 //z = 501; -> oki 501 z = 1/2; Ris = Double.toString(z); char item = '.'; int position = Ris.lastIndexOf(item); //restituisce -1 se non trova il punto String appo = Ris.substring(position+1,Ris.length()); if(Integer.parseInt(appo) > 0) z = Double.parseDouble(Ris.substring(0,position)) + 1;//arrotondo this.interosup=z; }
Il problema č che se passo un valore che risulta da una divisione, non funziona... (z=1/2=0,5) dovrebbe restituire 1, invece 0,0
Come fare????