嗯……它自己又好了……
不过除还是有点问题,div()效果还是不行package beans;
public class Div {
private int sba;
private int xba;
private int sbb;
private int xbb;
public int getSba() {
return sba;
}
public void setSba(int sba) {
this.sba = sba;
}
public int getXba() {
return xba;
}
public void setXba(int xba) {
this.xba = xba;
}
public int getSbb() {
return sbb;
}
public void setSbb(int sbb) {
this.sbb = sbb;
}
public int getXbb() {
return xbb;
}
public void setXbb(int xbb) {
this.xbb = xbb;
}
public String div(){
String rs = null;//sba:a的实部,xba:a的虚部
if((float)((xba*sbb - sba*xbb)/(sbb*sbb + xbb*xbb)) > 0)
rs = ((float)(sba*sbb + xba*xbb)/(sbb*sbb + xbb*xbb)) + "+" + ((float)(xba*sbb - sba*xbb)/(sbb*sbb + xbb*xbb)) + "i";
else if((float)((xba*sbb - sba*xbb)/(sbb*sbb + xbb*xbb)) < 0)
rs = ((float)(sba*sbb + xba*xbb)/(sbb*sbb + xbb*xbb)) + "" + ((float)(xba*sbb - sba*xbb)/(sbb*sbb + xbb*xbb)) + "i";
else
rs = ((float)(sba*sbb + xba*xbb)/(sbb*sbb + xbb*xbb)) + "";
//(a+bi)/(c+di)=(ac+bd)/(c2+d2) +((bc-ad)/(c2+d2))i
return rs;
}
}
|