Bug #12336 "DECIMAL ADD DECIMAL" RESULT A NON EXACT NUMRIC?

Submitted: 3 Aug 2005 7:34 Modified: 3 Aug 2005 8:38
Reporter: tony chen Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.1.13 OS:Linux (Mandrike Linux 8.1)
Assigned to: CPU Architecture:Any

[3 Aug 2005 7:34] tony chen
Description:
I dowload  LINUX X86 RPM PACKAGES(4.1.13-0 ,11.7M) , AND INSTALL IT.
I find some problem when compute two decimal type number.
these problem are not occur in MySQL 4.1.5

How to repeat:
1.
CREATE TABLE TEST (
     T_1 INT NOT NULL,
     N_1 DECIMAL(10,2) NOT NULL,
     N_2 DECIMAL(10,2) NOT NULL,
     PRIMARY KEY (T_1)
)

2.  INSERT INTO TEST VALUES (1, 1.10,      -1.10)
     INSERT INTO TEST VALUES (2, 1605.00, -1605.00)
     INSERT INTO TEST VALUES (3, 338.70,   -338.70)

3.  SELECT * ,N_1+N_2 FROM TEST WHERE N_1 + N_2 <>0  (WRONG)

T1         N_1          N_2          N_1+N_2
----------------------------------------
1          1.10         -1.10         0.00
3        338.70     -338.70       -0.00

4.  SELECT * FROM TEST WHERE N_1<> -1 * N_2  (CORRECT)

T1         N_1          N_2
----------------------------------- 
NONE
[3 Aug 2005 8:38] Aleksey Kishkin
Tony,

Prior to MySQL 5.0.3, decimal values could have up to 254 digits. However, calculations were done using floating-point and thus were approximate, not exact.

Since 5.0.3 decimal ariphmetic is exact.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.050 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
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.