What is the argument for printf that formats a long?
Put an l (lowercased letter L) directly before the specifier.
Put an l (lowercased letter L) directly before the specifier.
When you convert double to int,the precision of the value is lost. For example, When you convert 4.8657 (double) to int.The int value will be 4.Primitive int does not store decimal numbers.So you will lose 0.8657. In your case,0.7 is a double value(floating point treated as double by default unless mentioned as float-0.7f). When you calculate price*much*0.7 ,the answer is a double … Read more
long and long int are identical. So are long long and long long int. In both cases, the int is optional. As to the difference between the two sets, the C++ standard mandates minimum ranges for each, and that long long is at least as wide as long. The controlling parts of the standard (C++11, … Read more
You are multiplying ints together, and overflow occurs because the maximum integer is 2^31 – 1. Only after the multiplications does it get converted to a long. Cast the first number as a long. or use a long literal: That will force long math operations from the start.