I'm just looking through my lecture notes to finish off my assignment and have noticed something in the notes - float4.
I can't find an explanation of what it is/does in them and I don't have my books with me at the moment. Can someone tell me what float4 is and what it does please?Guessing from the name, it may be a data type. But there is no FLOAT4 in SQL - neither a data type with that name nor anything else is named that way in the standard.|||FLOAT(p) [UNSIGNED] [ZEROFILL]
A floating-point number. p represents the precision. It can be from 0 to 24 for a single-precision floating-point number and from 25 to 53 for a double-precision floating-point number. These types are like the FLOAT and DOUBLE types described immediately following. FLOAT(p) has the same range as the corresponding FLOAT and DOUBLE types, but the display width and number of decimals are undefined. As of MySQL 3.23, this is a true floating-point value. In earlier MySQL versions, FLOAT(p) always has two decimals. This syntax is provided for ODBC compatibility. Using FLOAT might give you some unexpected problems because all calculations in MySQL are done with double precision.
helps? :)|||I'd think the "4" refers to the storage length in bytes.
As opposed to the other two often used, viz. "float-8" and "float-16". (The latter is e.g. available in the C and C++ programming languages.)
I believe that most relational systems use the term "FLOAT" or "REAL" for float-4, and the term "DOUBLE" for float-8.
Since typically 3 of the 4 bytes are used for the mantissa and 1 for the exponent and the signs, a quick calculation shows that the precision of a float-4 will be about 7 digits (24 bits), while for a float-8 it will be about 14 digits (48 bits).
If I'm not mistaken, the mySQL "p" refers to the number of bits in the precision; hence a FLOAT (or float-4) is most often a FLOAT(24), while a DOUBLE (or float-8) is most often a FLOAT(48).
没有评论:
发表评论