Current location - Education and Training Encyclopedia - Education and training - Reasons for the failure of variable assignment in Java programming
Reasons for the failure of variable assignment in Java programming
Because this is written in integer processing, when the result of division is less than 1, it becomes 0. /When the numbers on both sides are integers, this symbol means divisible. Only when one of the two parties has higher accuracy, the higher accuracy shall prevail. So you can write

One; one

=

1.0d/(I * 2- 1);

Or an =1.0f/(I * 2-1);

In this case, the result will become double or float, which supports decimals.