Home  >  Article  >  Backend Development  >  Some views on php cout<<_PHP Tutorial

Some views on php cout<<_PHP Tutorial

WBOY
WBOYOriginal
2016-07-21 15:41:17775browse

That is, the sum of the digits of the integer and the decimal should not exceed 6 digits. If the decimal part is too long, the system will round it to approximately 6 digits. If the integer part is too long, it will also be approximately 6 digits

For example:
cout<<123.4567 results in 123.457,
cout<<123.4564 results in 123.456,
cout<<123456.1 results in 123456,
cout<<123456.5 results in 1 23457
Theoretically, constant strings are infinitely long, but due to limitations of the VC++ compiler, if the constant string is long enough to cause line breaks, it will cause a compilation error. In other words, cout<< followed by For constant strings, the length of the string is limited to 1 line in the compiler.
For the case of adding a variable after cout<<:
Let’s talk about the case with decimals first, which is slightly different from the constant number. The output result is related to the type of the variable. The int type is output according to the prototype, and the double type is output. 6 digits or less (including 6 digits) are output as prototypes, and 6 digits or more are output as Science and Technology Law forms. Other types are similar. By the way, the range of int type is -214783648~214780647, a total of 2^32 power numbers. Even if it goes out of bounds during assignment, the compiler will not report an error or warn, so be careful. There is common sense. If To represent the global population (about 6 billion), double or long double type should be used, other types are not acceptable; for variable strings, that is, char arrays, I did not find any restrictions, because I wrote:
char v [50000];
memset(v,1,49999);
cout<, countless little round faces (ASCII code 1) appeared on the screen characters), even if you use memset to assign values ​​out of bounds, there will be no problem.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/321187.htmlTechArticleThat is, the sum of the integers and decimals should not exceed 6 digits. If the decimal part is too long, the system will It is approximated to 6 digits by rounding. If the integer part is too long, it is also approximated as...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn