MySQL Forums
Forum List  »  Newbie

Re: The use of Float !?
Posted by: Felix Geerinckx
Date: August 16, 2005 01:57AM

in er wrote:

> I have the table structure seen below.
> When inserting hcp which is float I always get the result 9.9 ?
> mysql> insert into hcp values (null,4,'2005-08-13',10.0);
> Then:
> mysql> select * from hcp; and the last value is now 9.9 ??
> ...
> hcp | float(2,1) | | | 0.0

From http://dev.mysql.com/doc/mysql/en/numeric-types.html:

MySQL allows a non-standard syntax: FLOAT(M,D) or REAL(M,D) or DOUBLE PRECISION(M,D). Here, “(M,D)” means than values are displayed with up to M decimal digits in total, of which D decimal digits may be after the decimal point.

From this:

the largest number you can store in your float(2,1) column is 9.9. Everything (e.g. 10.0) larger than 9.9 will be truncated to 9.9. You get a warning about this. Why are you using float(2,1)? Why are you using float at all?

--
felix
Please use BBCode to format your messages in this forum.

Options: ReplyQuote


Subject
Written By
Posted
August 13, 2005 10:11AM
August 14, 2005 11:31PM
August 16, 2005 01:21AM
Re: The use of Float !?
August 16, 2005 01:57AM


Sorry, you can't reply to this topic. It has been closed.

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.