开发者

Throwing an exception if, for example, int a = Integer.MIN_VALUE-1; [closed]

开发者 https://www.devze.com 2023-03-31 13:55 出处:网络
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post.
Closed. This question needs details or clarity. It is not currently accepting answers.

Want to improve this question? Add details and clarify the problem by editing this post.

开发者_如何学Python

Closed 8 years ago.

Improve this question

Do you know of any languages which would throw an Exception on Overflow or Underflow? Thanks


.Net framework has a dedicated exception for Overflow

OverflowException Class


In C# you can let underflow and overflow throw exceptions using the checked keyword:

int a = checked(Integer.MIN_VALUE - 1);
0

精彩评论

暂无评论...
验证码 换一张
取 消