Difference between float(2,2) and float() in mysql

float(2,2) means "use two digits, of which two are used after the decimal point".

Hence, you can go from -0.99 to 0.99. You can't insert 10 into this column, you'd need atleast two digits before the comma (so float(4,2) or float(2,0)).

MySQL permits a nonstandard syntax: FLOAT(M,D) or REAL(M,D) or DOUBLE PRECISION(M,D). Here, “(M,D)” means than values can be stored with up to M digits in total, of which D digits may be after the decimal point. For example, a column defined as FLOAT(7,4) will look like -999.9999 when displayed. MySQL performs rounding when storing values, so if you insert 999.00009 into a FLOAT(7,4) column, the approximate result is 999.0001.


MySQL permits a nonstandard syntax: FLOAT(M,D) or REAL(M,D) or DOUBLE PRECISION(M,D). Here, “(M,D)” means than values can be stored with up to M digits in total, of which D digits may be after the decimal point.


In MySql, There are data type like FLOAT(M,D).Where D is the number of decimals and M is the total number of digits (including decimals).Decimal precision can go to 24 places for a FLOAT and M range 1 to 65. If syntax is FLOAT(2,2), then there have only two decimal place and no place to real number.So you want to add 10 you can use like FLOAT(5,2).