zoukankan      html  css  js  c++  java
  • java 类型转换:

    数值数据类型:

    1.自动类型转换

      byte->short ->int->long-->float--->double

      范转小的类型向范围大的类型号转换,由系统自动完成  [不会丢失精度],

          但loat和double在进行转换时候,有可能损失精度

      但byte和short 运算系统自动转换成int

      eg:   

          byte b=20;

          short s=b;

          s=s+b;    //b->short + b=40        //40转换为int  会出错误:高级不能换为低级类型

          特例:byte 与short 进行 算术运算时,他们结果转换为int

     

    2.强制类型转换

        byte<-short <-int<-ong<-float<-double

       (转换类型)数值

         当数值在 (转换类型范围内),不丢数据

         当数值在 (转换类型范围外),丢数据,不准确

         

  • 相关阅读:
    Mysql任务调度
    使用 IntraWeb (18)
    使用 IntraWeb (17)
    替盛大代发的招聘启示
    使用 IntraWeb (16)
    使用 IntraWeb (15)
    使用 IntraWeb (14)
    使用 IntraWeb (13)
    使用 IntraWeb (12)
    使用 IntraWeb (11)
  • 原文地址:https://www.cnblogs.com/zengkefu/p/5583107.html
Copyright © 2011-2022 走看看