如何对形如"1234556666"的String类型进行加减操作?我想过用Integer.parseInt()方法,但对于超过int所能存储的位数,就不行了.
如何"123456666".
请高手指点
如何"123456666".
请高手指点
解决方案 »
- UnkownAddressException找不到符号
- 请教高手:在线等待 关于字符串处理a/u.c/b/g.c/k/...
- 在java中 是否有和exit sub 功能一样的指令?
- 有两个关于线程的问题不明白,请德高望重的高手的指点一下,谢谢了!!分不够再加!
- 北大青鸟的培训效果好吗?
- 请问我如何知道一个线程是否阻塞了(任何原因)
- (送分)如何把java文件编绎成exe文件?
- 有谁知道Editplus2的注册码?
- javax.swing.swingUtilities.invokeLater方法
- 求UltraEdit v21.30.1016.0版激活验证码
- 请教一个关于日期的问题
- 怎样写MANIFEST.MF文件使一个可执行的.jar文件可以共享其它目录下的jar文件呢?
int newIntNum=Integer.parseInt(old); //可以这样吧?/
public TestBigDecimal(){}
public long add(long one, long other){
return one + other;
}
public BigDecimal add(BigDecimal one, BigDecimal other){
return one.add(other);
}
public long multiply(long one, long other){
return one*other;
}
public BigDecimal multiply(BigDecimal one, BigDecimal other){
return one.multiply(other);
}
public static void main(String[] args){
TestBigDecimal test = new TestBigDecimal();
long longOne = (long)(Math.random()*1E19);
long longOther = (long)(Math.random()*1E19);
BigDecimal one = BigDecimal.valueOf(longOne);
BigDecimal other = BigDecimal.valueOf(longOther);
System.out.println (longOne+" + "+longOther+" = "+test.add(longOne,longOther));
System.out.println (one+" add "+other+" = "+test.add(one,other));
System.out.println (longOne+" * "+longOther+" = "+test.multiply(longOne,longOther));
System.out.println (one+" multiply "+other+" = "+test.multiply(one,other));
}
}