Enum: enum, which implements the design of all possible results, in fact the data stored must be one of the well-defined data. Enumeration is defined using: Enum (the list of possible elements);//such as enum (' Male ', ' female ') used: storing data, only storing the above defined data to create an enumeration table-creating an enumeration table create table My_enum (gender enum (' Male ', ' female ' Confidentiality ')) charset UTF8; Insert data: One of the functions: Canonical data format, data can only be one of the specified data-insert the data insert into my_enum values (' Male '), (' Confidential '); --Valid data--error data insert into my_enum values (' Male '); --Error: No effect of this element two: Save storage space (enumeration usually has an alias: Radio box), the enumeration is actually stored in the value, not the string itself in MySQL, the system is also automatically converted format, and basically the same as PHP (especially string to number) The data stored in the Proof field is numeric: The data is removed by +0 to determine whether the original data is stored in the end is a string or a value, if the final result of the string is always 0, otherwise is another value-the field results are taken out for +0 operations Select Gender + 0,gender from my _enum; Find out the actual law of the enumeration elements: according to the order in which the elements appear, the enumeration principle is numbered starting from 1: When enumerating the data specifications (when defined), the system automatically establishes a corresponding relationship between the number and the enumeration element (the relationship is placed in the log), and when the data is inserted, The system automatically converts the characters into corresponding digital stores, and then, when the data is extracted, the system automatically converts the numbers into string displays. The reason for the inaccuracy of the operation of the double type: n binary can be understood as: the power of the number x cardinality, such as the decimal number we are familiar with 123.4=1x102+2x10+3x (10 of the power of 0) +4x (10-1 power); The same is true of the other binary, such as binary number 11.01=1x 2+1x (Power of 2 0) +0+1x (2 to 2 power) = decimal 3.25. A value of type double takes 64bit, or 64 binary numbers, except that the highest bit represents the positive and negative sign, and the lowest bit is bound to have an error with the actual data (unless the actual data is exactly 2 of the n-th square).
For example, for example, to use 4bit to represent decimal 3.26, from high to low to correspond to 2 1,0,-1,-2 power, according to the top of the analysis, should be in the binary number 11.01 (corresponding to the decimal 3.25) and 11.10 (corresponding to the decimal 3.5) between the selection.
In short, we give the value, in most cases need more than 64bit more digits to accurately represent (even need infinity), and the double type of the value of only 64bit, the back of the number of bits will definitely bring error, can not get "mathematically accurate" results.
Hands-on brain supplement