posts - 397,comments - 0,views - 25332
强制类型转换一般不推荐使用,因为有可能发生精度损失、数据溢出。
byte/short/char这三种类型都可以发生数学运算,例如加法”+".
byte/short/char这三种类型在运算的时候,都会被首先提升成为int类型,然后再计算。
复制代码
 int num = (int) 100L;
        System.out.println(num);
        //long强制转换成为int类型
        int num2 = (int) 6000080000L;
        System.out.println(num2);
        // 1705032704l/double --> int,强制类型转换
        int num3 = (int)3.99;
        System.out.println(num3);
        //这并不是四舍五入,所有的小数位都会被舍弃掉
        byte num4 = 40;
        byte num6 = 60;

        short result2 = (short)(num4 + num6);
        System.out.println(result2);
复制代码

 

 

 

 

 

ASCII编码表

ASCII码表: American Standard Code for Information Interchange,美国信息交换标准代码。

Unicode码表:万国码。也是数字和符号的对照关系,开头0-127部分和ASCII完全一样,但是从128开始包含有更多字符。

48-‘0’

65-‘A’

97-'a'

 

 

 

 

 

 

posted on   淤泥不染  阅读(97)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示