4 Numbers
This chapter covers
- Problems due to numeric overflow or rounding
- Mistakes that can occur when handling special numbers, such as
Integer.MIN_VALUE
or-0.0
- How to avoid mistakes when doing bit manipulation and using hexadecimal numbers
- Caveats in seemingly simple numerical algorithms, such as oddness check and clamping
- Why it’s better to avoid certain numeric data types
Modern programs usually operate with very high-level abstractions. Still, numbers and primitive math is used by programmers quite often. Unfortunately, computer math differs in many ways from real math, and these differences often produce unpleasant bugs. An experienced Java programmer should be aware about many peculiarities of number processing in this language, ...
Get 100 Java Mistakes and How to Avoid Them now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.