zoukankan      html  css  js  c++  java
  • 10.3日报

    如下程序:


    public class Test {
     public static void main(String[] args) {
      // TODO 自动生成的方法存根
      int intValue=100;
      long longValue=intValue;
      double doubleValue=1234567890;
      float floatValue=(float)doubleValue;
      System.out.println(floatValue);//1.23456794E9
      
      int X=100;
      int Y=200;
      System.out.println("X+Y="+X+Y);
      System.out.println(X+Y+"=X+Y");
      doNotRunme();
      
      String string="";
      double d1=1000.123;
      double d2=1000.123;
      if(Math.abs(d2-d1)<1e-10){
       
      }
      //System.out.println(string);
     }
     public static void doNotRunme()
     {
      doNotRunme();
     }
     }
     程序运行结果是:
    1.23456794E9
    X+Y=100200
    300=X+Y
     
    如下程序:
    import java.math.BigDecimal;
    public class TestBigDecimal {
     public static void main(String[] args) {
      // TODO 自动生成的方法存根
      BigDecimal f1 = new BigDecimal("0.05");
      BigDecimal f2 = BigDecimal.valueOf(0.01);
      BigDecimal f3 = new BigDecimal(0.05);
      System.out.println("下面使用String作为BigDecimal构造器参数的计算结果:");
      System.out.println("0.05 + 0.01 = " + f1.add(f2));
      System.out.println("0.05 - 0.01 = " + f1.subtract(f2));
      System.out.println("0.05 * 0.01 = " + f1.multiply(f2));
      System.out.println("0.05 / 0.01 = " + f1.divide(f2));
      System.out.println("下面使用double作为BigDecimal构造器参数的计算结果:");
      System.out.println("0.05 + 0.01 = " + f3.add(f2));
      System.out.println("0.05 - 0.01 = " + f3.subtract(f2));
      System.out.println("0.05 * 0.01 = " + f3.multiply(f2));
      System.out.println("0.05 / 0.01 = " + f3.divide(f2));
     }
    }
     
    程序运行结果:
    0.05 + 0.01 = 0.06
    0.05 - 0.01 = 0.04
    0.05 * 0.01 = 0.0005
    0.05 / 0.01 = 5
    下面使用double作为BigDecimal构造器参数的计算结果:
    0.05 + 0.01 = 0.06000000000000000277555756156289135105907917022705078125
    0.05 - 0.01 = 0.04000000000000000277555756156289135105907917022705078125
    0.05 * 0.01 = 0.0005000000000000000277555756156289135105907917022705078125
    0.05 / 0.01 = 5.000000000000000277555756156289135105907917022705078125
     
     
  • 相关阅读:
    Python网络爬虫第三弹《爬取get请求的页面数据》
    18.增量式爬虫
    17.基于scrapy-redis两种形式的分布式爬虫
    关于进程内存磁盘的一些命令
    linux其他命令
    ls -用于显示指定工作目录下之内容(列出目前工作目录所含之文件及子目录)
    mkdir和touch
    ls -列出当前目录下所有的文件或者目录
    cat -用于连接文件并打印到标准输出设备上
    rm -移动文件
  • 原文地址:https://www.cnblogs.com/cdl-sunshine/p/13765596.html
Copyright © 2011-2022 走看看