zoukankan      html  css  js  c++  java
  • 计算99的99次幂

    package japan.example.test;
    
    import java.math.BigDecimal;
    import java.math.BigInteger;
    import java.text.DecimalFormat;
    
    public class Nine9Test {
    
        public static void main(String[] args) {
    
            double d = Math.pow(100, 100);
            System.err.println(d);
    
            Nine9Test test = new Nine9Test();
            BigInteger f = test.test(new BigInteger("100001"), 1000);
    
            BigDecimal b = new BigDecimal(f);
            DecimalFormat df = new DecimalFormat("#.#####E0");
            df.setMinimumFractionDigits(2);
            df.setMaximumFractionDigits(2);
            String display = df.format(b);
            System.err.println(display);
        }
    
        @Deprecated
        public double test(double d, int p) {
            double r = 1.0d;
            for (int i = 0; i < p; i++) {
                r *= d;
            }
    
            return r;
        }
    
        public BigInteger test(BigInteger d, int p) {
            BigInteger r = new BigInteger("1");
            for (int i = 0; i < p; i++) {
                r = r.multiply(d);
            }
    
            return r;
        }
    }
  • 相关阅读:
    20140327工作室日志
    20140326学习工作室日志
    标准连接池实现
    JDBC
    监听器
    数据表多对多
    MATLAB 中几个颜色空间的坐标范围
    RabbitMQ(一)
    Web Service之Axis(二)
    Web Service之CXF(四)
  • 原文地址:https://www.cnblogs.com/jpit/p/8444123.html
Copyright © 2011-2022 走看看