What are the differences between 1+1d/5 and 1DB / java in java
This article mainly introduces "what is the difference between 1+1d/5 in java and 1x5x5". In daily operation, I believe that many people have doubts about the difference between java and 1+1d/5. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the question of "what is the difference between 1+1d/5 in java and 1x5x5"! Next, please follow the editor to study!
Catalogue
The difference between java 1+1d/5 and 1 / 1 / 1 / 2 / 5
The main difference is that the data types are different
Calculate 1 pound, 1 beat, 2 steps, 3 steps, 20 steps! Sum
The main difference between java 1+1d/5 and 1: 1 / 5 is that the data types are different.
The result of 1+1d/5 is 1.2, which is of type double. Because 1D is the double type, the 1d/5 result is automatically promoted to the double type and the 1+1d/5 result is automatically promoted to the double type. .
The result 1 of 1 is int, because 1 is divisible (will lose the precision of the decimal part.) . Both operands are of type int. Finally, add 1 or int type. So the result is the int type.
The java reference code is as follows
Public class Test {public static void main (String [] args) {double num1 = 1 + 1D / 5; System.out.println (num1); / / output 1.2 int num2 = 1x 1 / 5; System.out.println (num2); / / output 1}} calculates 1x, 1max, 2pm, 2pm, 1max, 1max, 2pm, 1max, 2k, 2k, 2k, 2s, 2s, 2s, 2s, 1s, 2s, 1s, 2s, 1s, 2s, 1s, 2s, 1s, 2s, 1s, 2s, 1s, 2s, 1s, 1s, 2s, 1s, 1s, 2s, 1s, 2s, 1s, 1s, 2s, 1s, 1s, 2s, 1s, 1s, 2s, 1s, 1s, 2s, 1s, 1 Sum
The original title: calculate 1 pound, 1 pound, 2 cycles, 1 stroke, 3 cycles +. + 1PUX 20! Sum
Observe the topic, the difficulty of this question is to calculate the factorial, you might as well use a cycle to calculate the factorial, and then use a cycle to calculate from 1 to 1! To 1x20! Donovan and. The code is as follows
Package java1;public class sum {public static void main (String args []) {/ / denote the factorial result int slots 1 with s; double sum=0; / / calculate 1 prime 1! To 1x20! And for (int iTune1)