Float(n) |
|||||||||||||||||||||||||||||||||||||||||||||||
Once in a social network was asked how to remove trailing zeros in decimal numbers. This was associated with the preparation of a report, which sums concatenate with the text. In the conditions of the problem was stated limit to two decimal places. Here's an example of data and the desired result:
Solutions have been proposed, based on analysis of the line. I also chose the wrong way and proposed the following solution:
I do not know how much it would still be continued, if one member did not notice that all problems are solved by conversion to the data type Òèï äàííûõ ñ ïëàâàþùåé òî÷êîé. float. Really:
However, you need to remember the approximate nature of this type, namely the magnitude of the mantissa in scientific representation of the number. In accordance with the standard in this type of data specified argument - FLOAT (n), which can take values from 1 to 53. The SQL(Structured Query Language) is a database computer language designed for the retrieval and management of data in relational database management systems (RDBMS), database schema creation and modification, and database object access control management.SQL Server, an argument value in the range 1 – 24, interprets it as 24, which corresponds to the accuracy of 7 digits, and in the range 25 - 53 as 53, which corresponds to the accuracy of 15 digits. The default is 53. The following example illustrates the above:
MySQL (version 5.0) Does not support the conversion to type FLOAT. PostgreSQL (version 8.3.6) Almost similar behavior, except that for the parameter in the range 1 - 24 precision is 6 digits. Accordingly, recent results will look like this:
|