...
The upcast technique is the preferred approach when applicable. The checks it requires are simpler than those of the previous technique; it is substantially more efficient than using BigInteger
. Unfornately Unfortunately it cannot be applied to operations involving the biggest type long
, as there is no bigger type to upcast to.
...
NUM16-EX0: Depending on circumstances, integer overflow could be benign. For instanceexample, many algorithms for computing hashcodes hash codes use modular arithmetic, intentionally allowing overflow to occur. Any computation where overflow is expected and allowed must explicitly document this fact.
Risk Assessment
Failure to perform appropriate range checking can lead to integer overflows, which can cause unexpected program control flow or unanticipated program behavior.
...
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="3da81d0ab8fe090e-51abfdc5-47e34f04-a7978df3-5cdd31390812a24251834dd4"><ac:plain-text-body><![CDATA[ | [[API 2006 | AA. Bibliography#API 06]] | class [ | http://download.oracle.com/javase/6/docs/api/java/util/concurrent/atomic/AtomicInteger.html] | ]]></ac:plain-text-body></ac:structured-macro> |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="a522c18f6c756ea2-5489eb97-48cc49d7-addf86a4-94382fb0aee7cf0fae95365a"><ac:plain-text-body><![CDATA[ | [[Bloch 2005 | AA. Bibliography#Bloch 05]] | Puzzle 27: Shifty i's | ]]></ac:plain-text-body></ac:structured-macro> | |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="ca07ca2a32b515cb-b6405ba2-4e1d402e-92929db4-52303605d7394f3a87ba2ce7"><ac:plain-text-body><![CDATA[ | [[SCG 2009 | AA. Bibliography#SCG 09]] | Introduction | ]]></ac:plain-text-body></ac:structured-macro> | |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="bd8350c787174798-7f40aa2f-493d43ff-83cb9589-0f2b236d1c5ef9f5f4fd88db"><ac:plain-text-body><![CDATA[ | [[JLS 2005 | AA. Bibliography#JLS 05]] | [§4.2.2, "Integer Operations" | http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html#4.2.2] | ]]></ac:plain-text-body></ac:structured-macro> |
| |||||
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="9e6e99b247b8c09e-8216f763-415747ca-a2b983c1-af881c3837583d6cb0e3ee49"><ac:plain-text-body><![CDATA[ | [[Seacord 2005 | AA. Bibliography#Seacord 05]] | Chapter 5. Integers | ]]></ac:plain-text-body></ac:structured-macro> | |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="3911f0b236930905-b369dfe0-435c43d0-90b09ff0-bfb09ad1cdf4dc69c866144c"><ac:plain-text-body><![CDATA[ | [[Tutorials 2008 | AA. Bibliography#Tutorials 08]] | Primitive Data Types | ]]></ac:plain-text-body></ac:structured-macro> |
...