CppPrimer.5th 01
2020-05-01 本文已影响0人
忻恆
The float and double types typically yield about 7and 16 significant digits, respectively.
整数部分 和 小数部分一共7位。
单精度数的尾数用23位存储,加上默认的小数点前的1位1,2^(23+1) = 16777216。
因为 10^7 < 16777216 < 10^8,所以说单精度浮点数的有效位数是7位。
双精度的尾数用52位存储,2^(52+1) = 9007199254740992,
因为10^16 < 9007199254740992 < 10^17,所以双精度的有效位数是16位。
借图
在默认情况下以%f格式输出的情况下会输出6位小数,但并不能保证这6位小数有效。
there are three distinct basic character types: char,signed char, and unsigned char.
Which of the other two character representations is equivalent to char depends on the compiler.
Rules of thumb 经验法则
• Use an unsigned type when you know that the values cannot be negative.
• Use int for integer arithmetic. short is usually too small and, in practice, long often has the same size as int. If your data values are larger thanthe minimum guaranteed size of an int, then use long long.