Java高精度計算
import java.math.BigDecimal;
public class Main{
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
BigDecimal a = cin.nextBigDecimal();
BigDecimal b = cin.nextBigDecimal();
//高精度浮點數相加
System.out.println(a.add(b));
//高精度浮點數相減
System.out.println(a.subtract(b));
//高精度浮點數相乘
System.out.println(a.multiply(b));
//高精度浮點數相除
System.out.println(a.divide(b));
//高精度浮點數取模
System.out.println(a.remainder(b));
//高精度浮點數取模並保留小數
System.out.printf("%.9f",a.remainder(b));
}
}