views:

173

answers:

4

Hi,

I am entering '35444650.00' as a float into my MySQL and it keeps reformatting to 35444648.00, any help welcome...

+6  A: 

Floats only have a certain level of precision, you may be going beyond how precise a float data type can be. Try using a DOUBLE instead.

tloach
A: 

You are going past the level of precision possible. You need to define the float with more precision, i.e. "FLOAT(10,5)" would mean a float that can have 10 digits total with up to five after the decimal point.

Brian Schroth
+3  A: 

A float has 6 digits of precision. Use a double to get 15 or switch to a numeric(x,y). If you're interested, check out the storage requirements for MySQL for the different data types.

Gonzalo
+3  A: 

A higher precision alternative to float is DOUBLE. But looking at the example, I think the DECIMAL datatype might come in handy if the number of digits required after zero is small (around 2-4) and the number of digits before decimal is also small (around 10-12).

Salman A