----- Original Message ----- 
From: "Tatjana Cukic" <[EMAIL PROTECTED]>
To: "MYSQL ANSWERS" <mysql@lists.mysql.com>
Sent: Wednesday, October 26, 2005 4:05 AM
Subject: Problem with decimal values


> Hi People,
>
> it is strange, i am using MySQL version 4.1 (so dont
> expect some bugs) on Windows 2000, and if i create a
> field (e.g. temperature) as
>
> temperature decimal(4,3)
>
> if i wanna insert the value 100, it is storing as
> 99.999
>
> does anybody knows the reason why doesnt show it as
> 100.000 but as 99.999 when my size is defined as 4 but
> not 2
>
> Thanks a lot!

In SQL, a definition of a DECIMAL column usually follows this pattern:
DEC(x,y). In this pattern, 'x' is the number of digits in the entire number,
i.e. the number of digits on BOTH sides of the decimal point, and 'y' is the
number of decimal places.

Therefore, when you define your decimal as DEC(4,3), you are saying that
there will never be more than 4 digits in the entire number and three of
those digits will be decimal places. The largest number you can store in a
DEC(4,3) column is 9.999. If you want to be able to store 100 (or rather
100.000), you will need to change your definition to DEC(x,3) where 'x' is
any value greater than or equal to 6.

Rhino



-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.361 / Virus Database: 267.12.5/149 - Release Date: 25/10/2005


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to