assignment of 'small' to non-'small' should not call 'Util.toInt()'
See original GitHub issueI made a mistake during the discussion in #6038.
Answering quickly, I didn’t think through the implications of throwing an OverflowException
.
Here’s the reasons why not to do that:
- We don’t generally check for numeric overflow. We generally wrap around silently.
- Calling a whole method has the potential to suddenly change the performance characteristics of a numeric algorithm, making them much worse, in a way that is not at all predictable to the programmer.
- The very first usecase for
small
that I ran into simply broke because of this.
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Why can I assign an integer literal to a short type variable but ...
In order to understand why the assignment type-conversion works whilst the invocation one is rejected, one has to refer to the Java Language ......
Read more >parseInt() - JavaScript - MDN Web Docs
the radix as a 32-bit integer is smaller than 2 or bigger than 36 , or ... parseInt() does not treat strings beginning...
Read more >Chapter 5. Conversions and Promotions
The conversion process for such operands is called numeric promotion. Promotion is special in that, in the case of binary operators, the conversion...
Read more >Why don't Java's compound assignment operators require ...
The Problem When you assign two variables with different primitive types – for example long to int – you need to use casting....
Read more >Java Basics - Java Programming Tutorial
This chapter explains the basic syntaxes of the Java programming language. I shall assume that you have written some simple Java programs.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For everything, I think.
I guess this can be closed now?