Puzzle
Byte is signed. The range is-128-127.
And 0x90 is of type int.
Compared to the time. Not equal.
Suppose you want to make it equal, you need to convert the type: (Byte & 0xFF) or (byte) 0x99.
Puzzle
The effect of the self-increment operator on the loop. J = j + +, first assigned.
Puzzle
Integer.max_value will become integer.min_value after adding one. This will have an impact on the loop.
you
can consider using long to represent the I variable, or use the more efficient I! = Integer.max_value.
Puzzle
( -1 << 32) results are-1 instead of 0.
The data shift operation for int type always takes the right end number to the lower five bits of the 2 binary.
for long data shift operations always take the right-hand number to the lower six bits of the 2 binary.
32 lower five bits is 0. So the result is-1. Assuming that the number on the right is negative, the same remains low by five (six) bits and converted to positive numbers.
while (i = = i + 1) {
}
i = i + 1 when the floating-point number I is large enough.
The distance between adjacent floating-point numbers is called ULP (unit int the last place), once the ULP exceeds 2. Plus one will not have any effect whatsoever.
Binary floating-point arithmetic is just an approximation.
Puzzle
While
(i! = i) {
}
IEEE 754 floating-point arithmetic retains a special value: NaN (not a number).
Double i = 0.0/0.0. Double i = Double.NaN,
regardless of the floating-point operation, only one or more operands are Nan, and the result is Nan.
nan does not equal any floating-point number, including itself. Nan! = Nan.
Puzzle
While
(i! = i + 0) {
}
I! = i + 0, assuming I is a string type. At this point the + is not the arithmetic plus sign, and is overloaded with a string of connections.
Puzzle
While
(i! = 0) {
I >>>= 1;
}
or are you talking about type conversions?
when I is 1 of the short type, I >>>= 1, which is still-1: first converts the short to int. Then intercept the low 16.
no matter what the negative number of Short,byte will eventually be converted to-1. Char does not, and char is unsigned.
Puzzle
integer i = new Integer (0);
Integer j = new Integer (0);
while (i <= J && I >= j && i! = j) {
}
wrapper class, when using the = = operator, it is not inferred that the values are equal but references (compatibility considerations).
<= or >= are value inference.
the puzzle.
while (i! = 0 && i = =-i) {
}
integer boundary problem
0x8000 0000 represents the smallest negative number (Integer.min_value), which is the inverse of it, is still itself.
puzzle
Final int START = 2000000000;int count = 0;for (float f = start; F < start + N; f++) {count++; System.out.println (START + 65);}
floating point accuracy problem The start+50 is equal to START when the floating-point number is used. 50 is smaller than half of the ULP distance (128) of start.
When more than half of the distance of ULP, infinite loop.
Puzzle
The remainder and the multiplication have the same superior first grade.
Copyright notice: This article blog original articles, blogs, without consent, may not be reproduced.
Java FAQ 3: The Mystery of the cycle