Bug #33916 Math error, with types (POW())
| Submitted: | 18 Jan 2008 11:24 | Modified: | 19 Jan 2008 9:42 |
|---|---|---|---|
| Reporter: | Colin Charles | Email Updates: | |
| Status: | Not a Bug | Impact on me: | |
| Category: | MySQL Server | Severity: | S3 (Non-critical) |
| Version: | 5.0.45,5.0.53bk | OS: | Linux (x86_64) |
| Assigned to: | CPU Architecture: | Any |
[18 Jan 2008 11:24]
Colin Charles
[18 Jan 2008 11:51]
Alexey Kopytov
The results are inconsistent due to the intentional change in behavior introduced by the patch for bug #24912. Since "a-3" has the unsigned integer type, it evaluates to 18446744073709551615, so 3.4028236692094e+38 is the expected result of pow(a-3, 2).
[19 Jan 2008 9:42]
Valeriy Kravchuk
Manual (http://dev.mysql.com/doc/refman/5.0/en/arithmetic-functions.html) clearly says: "If one of the arguments is an unsigned integer, and the other argument is also an integer, the result is an unsigned integer." So, formally, it is NOT a bug. I'd prefer, though, to have this particular incompatible change (in GA!) of 5.0.42+ vs. older version to be explicitely documented in: http://dev.mysql.com/doc/refman/5.0/en/releasenotes-es-5-0-42.html
[21 Jan 2008 12:21]
Eduard Boer
When I have a tabel A_TABLE with an UNSIGNED TINYINT, I can do the following: select A,1-A,-A+1 FROM A_TABLE; result is: "10";"18446744073709551607";"-9" So the work around is to use "-A+1" instead of "1-A" What I'd like to know is how other databases would handle this. Because this behavior of mysql was a complete suprise to me.
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.053 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.