Forum Moderators: coopster

Message Too Old, No Replies

proper datatype for float (i.e. 70.30)

         

neophyte

8:49 am on Feb 12, 2006 (gmt 0)

10+ Year Member



Sorry if this off topic for this forum, but I couldn't find the regular "database" forum.

I'm using mysql and I need a table that reflects a float input. if I set the datatype to float, and input, say, 70.35, all is well. However, If I input something with a trailing zero (like 70.30) the final zero is stripped so I end up with 70.3.

My clients a real nit-pick, so he'll want the web display to show 70.30, and not 70.3.

Is there any datatype that will retain the trailing zero (and still be the correct data type for a float) rather than "text" or "varchar"?

Additionally, some small amount of math may need to be done via php when field contents are sent to variables - would selecting a datatype of "varchar" inhibit the ability to do mathmatical calculations?

Neophyte

Little_G

2:56 pm on Feb 12, 2006 (gmt 0)

10+ Year Member



Hi,

Looking at the MySQL reference,
http://dev.mysql.com/doc/refman/5.0/en/numeric-type-overview.html [dev.mysql.com]
The numeric type 'decimal' may work as it allows you to set the number of decimal places stored.

Andrew

maccas

3:17 pm on Feb 12, 2006 (gmt 0)

10+ Year Member



Try float and 2,2 in the Length/Values

neophyte

12:10 am on Feb 13, 2006 (gmt 0)

10+ Year Member



Little G and maccas -

Thanks to you both for your help. I've chosen float 3,2 which works perfectly.

Thanks again.

Neophyte