Bug #109149 The representation of 0 in MOD function in computing string
Submitted: 20 Nov 2022 5:01 Modified: 21 Nov 2022 5:17
Reporter: Chenglin Tian Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: DML Severity:S3 (Non-critical)
Version:8.0.31, 5.7 OS:Ubuntu
Assigned to: CPU Architecture:x86

[20 Nov 2022 5:01] Chenglin Tian
Description:
When we use the mod function to calculate, we find that if there is a negative number type string, the result will be inconsistent with the expectation

How to repeat:
The following is the test statement that we found the problem´╝Ü
SELECT mod(-12,-4); -- expected: 0, actual: 0 
SELECT mod('-12',-4); -- expected: 0, actual: -0   

Suggested fix:
This is a problem that we have detected that is inconsistent with the expected result. We believe that - 12 and '- 12' can be regarded as the same during type conversion, but we get two results: 0 and - 0. I don't know whether this is an exception
[21 Nov 2022 5:17] MySQL Verification Team
Hello Chenglin Tian,

Thank you for the report.

regards,
Umesh
[21 Nov 2022 8:37] Roy Lyseng
Workaround: SELECT MOD(CAST('-12' AS SIGNED), -4);