-
Notifications
You must be signed in to change notification settings - Fork 304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
两个 byte 相加,返回值的类型是int #4
Comments
谢谢指出这里的错误,去JLS里查找了以下,果然是有这样的说明的
https://docs.oracle.com/javase/specs/jls/se8/html/jls-5.html#jls-5.6.2
1.
Widening primitive conversion (§5.1.2
<https://docs.oracle.com/javase/specs/jls/se8/html/jls-5.html#jls-5.1.2>)
is applied to convert either or both operands as specified by the following
rules:
-
If either operand is of type double, the other is converted to double.
-
Otherwise, if either operand is of type float, the other is converted
to float.
-
Otherwise, if either operand is of type long, the other is converted
to long.
-
Otherwise, both operands are converted to type int.
我会联系编辑看如何进行修正。
gaokechen <[email protected]> 于2020年6月26日周五 下午9:04写道:
… 两个 byte 相加,返回值的类型并不是byte而是int,需要强制转换成byte。并且可能会超出数据有效范围出现异常值。
[image: 微信截图_20200626205929]
<https://user-images.githubusercontent.com/32739652/85859613-06a91600-b7f0-11ea-83b5-e6eb0c99eed8.png>
[image: 微信截图_20200626205518]
<https://user-images.githubusercontent.com/32739652/85859629-0c9ef700-b7f0-11ea-9d14-2a7e73515baa.png>
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#4>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAE2IT5WLOHTZFKCQHQIR33RYSMG3ANCNFSM4OJJ5QGQ>
.
|
专业👍👍👍 |
已经联系编辑同学了,极客时间的编辑同学会帮忙作出相应的修改的。谢谢~ |
视频和ppt已经修正,closing。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
两个 byte 相加,返回值的类型并不是byte而是int,需要强制转换成byte。并且可能会超出数据有效范围出现异常值。


The text was updated successfully, but these errors were encountered: