Bug #109119 | "CAST AS JSON" casts numeric values with big precision incorrectly | ||
---|---|---|---|
Submitted: | 17 Nov 2022 10:44 | Modified: | 17 Nov 2022 12:55 |
Reporter: | Damian Cholewa | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server: JSON | Severity: | S3 (Non-critical) |
Version: | 8.0.20 | OS: | Any |
Assigned to: | CPU Architecture: | Any | |
Tags: | cast, cast string, double, FLOAT, json, precision |
[17 Nov 2022 10:44]
Damian Cholewa
[17 Nov 2022 11:02]
Damian Cholewa
I would like to add if I add JSON value directly to the database by insert (for example {"end": 13.588410104011881}) then it shows correct value. So, only CAST AS JSON is causing a problem.
[17 Nov 2022 12:55]
MySQL Verification Team
Hi Mr. Cholewa, Thank you for your bug report. However, it is not a bug. Simply, CAST has to do the best it can. In your case, it supposes that you want a floating point value for that number. Hence it also has to suppose that it is the value of DOUBLE which has 15 (fifteen) significant digits, while 16th (sixteenth) should be included as well. However, you have 17 (seventeen) digits. Not a bug.