Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - In c++, double type is divided by integer. I hope the master can help me solve it. Thank you very much.
In c++, double type is divided by integer. I hope the master can help me solve it. Thank you very much.
The results before and after the change should be the same. This mainly involves type conversion in C++. 、

long int I = 0; //Declare and initialize I as a long integer.

term = 1.0/(I * I); //For the constant 1.0, the C++ compiler will automatically convert it into a double type, and this division will automatically convert an int into a double during the operation. This is an implicit conversion and the compiler will complete it automatically.

If it is declared as long double I = 0;; //The result is the same, except that no type conversion is required.

You can keep asking me if you don't understand.