This problem is mentioned in many places. "High Quality C Programming Guide" said a lot, I also want to say some. 1. About Float and Double. I remember to write a work control program, in order to adapt to the wide range of data, select the parameter type as Double type. However, the presence error of the DOUBLE type is found during the test, and as the incoming parameter is a = 1.00,000, but the obtained parameter value is A = 0.9999999987, etc. Later, it was thought that the judgment of Double data should use the range judgment, that is, this judgment: 1.00000-max_error
/ ******************************************** / The general floating point decimal is expressed in binary decimal, and the integer part is similar, and the decimal is also a power part of 2. It is only a negative number. For example: 0.5 (10) is expressed as 0.1 (2), it is popular, it is 2 ^ -1, that is, 1/2, the same: 0.25 (10) is expressed as 0.01 (2), ie 2 ^ -2, that is, 1/4. For a decimal, for example, 8-bit binary decimal, its actual value is the value of all bits, for example: 0.75 (10) = 0.11 (2) = 1/2 1/4 Therefore, there is a lot of values that are added like 0.1 (10), and 8-bit binary decimal is set. 0.1 (10) can be expressed as 0.00011001 (2) = 1/16 1/32 1/256 = 0.09765625 or 0.1 (10) can be expressed as 0.00011010 (2) = 1/16 1/32 1/128 = 0.1015625 Due to the binary representation of the No. 0.00011001 and 0.00011010 (relative to The 8-bit fixed-length binary decimal is, so it can only be used instead of 0.1, specifically taken the basis The actual rounding rules are determined, and there is an error. Therefore, for the binary decimal, only 2 negative decisions can be accurately expressed, otherwise There may be an error. / ************************************************** ************* / 2, BOOL and BOOL type. In fact, BOOL in C / C is defined as: typedef int bag; #define false 0 # Define True 1 This is to say that in fact, the BOOL type is int type, and the BOOL type is just a type of TRUE and FALSE. Since BOOL is an int type, it is particularly that TRUE is defined in -1 in VB. So don't compare values in True or 1 when compared, this is more dangerous! In addition, the Bool type and BOOL type defined in the MFC program can be mixed, but should pay attention to the length of these two types. I personally feel that if you use the MFC programming, it is best to use the Bool type True and False, at least People feel the same, huh, huh!