Planet MySQL Planet MySQL: Meta Deutsch Español Français Italiano 日本語 Русский Português 中文
Showing entries 1 to 2

Displaying posts with tag: decimal (reset)

MySQL Decimal datatype
+1 Vote Up -3Vote Down
The DECIMAL datatype is a datatype in MySQL that provides additional precision over FLOATs or DOUBLEs at the expense of arithmetic. You specify the precision by using
datatype-name DECIMAL
or
datatype-name DECIMAL(8)
or
datatype-name DECIMAL(10,4)

MySQL uses roughly 4 bytes for every 9 digits either side of the decimal.

The english definition (http://www.thefreedictionary.com/decimal) would assume that when you specify the DECIMAL datatype you would want to insert numbers with fractions.

This however is not the case. Lets show this:

mysql> create database decimal_madness;
Query OK, 1 row affected (0.00 sec)

mysql> use decimal_madness;
Database changed
mysql> create table test1 ( tmp

















  [Read more...]
Know your data – and your numeric types.
+0 Vote Up -0Vote Down
Numeric types in MySQL have two varieties: - “precise” types such as INTEGER and DECIMAL; - the IEEE-standard floating point types FLOAT and DOUBLE. As a rule of thumb, the first group are for exact, “counted” quantities. The INTEGER types represent whole numbers, and DECIMAL represents “fixed point” decimal, with a preset number of places after the decimal point. Various widths of INTEGER are available in MySQL, from 8-bit TINYINT to 64-bit BIGINT. Calculations with integer types are fast, as they usually correspond to hardware register sizes. DECIMAL is commonly used for quantities like decimal currency where the number of digits of precision is known and fixed. For example, exactly counting pennies in two decimal digits. Computation with DECIMAL is slower than other types, but this is unlikely to impact most applications. In the other category are FLOAT and DOUBLE,  [Read more...]
Showing entries 1 to 2

Planet MySQL © 1995, 2014, Oracle Corporation and/or its affiliates   Legal Policies | Your Privacy Rights | Terms of Use

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.