Bug #100489 negative operands with % yields -0 to be displayed
Submitted: 11 Aug 2020 4:17 Modified: 11 Aug 2020 5:42
Reporter: Yushan ZHANG Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Optimizer Severity:S3 (Non-critical)
Version:5.7.31, 5.6.48, 8.0.21 OS:Any
Assigned to: CPU Architecture:Any

[11 Aug 2020 4:17] Yushan ZHANG
Description:
mysql> select -1 % -1;
+---------+
| -1 % -1 |
+---------+
|       0 |
+---------+
1 row in set (0.01 sec)

-- incorrect, displays `-0`
mysql> SELECT price, price % price FROM t1;
+-------+---------------+
| price | price % price |
+-------+---------------+
|    -1 |            -0 |
+-------+---------------+
1 row in set (0.00 sec)

How to repeat:
select -1 % -1;

drop table if exists t1;

create table t1(
price float
);

insert into t1 values (-1);

SELECT price, price % price FROM t1;

Suggested fix:
fix the result when evaluating an expression with the field
[11 Aug 2020 5:42] MySQL Verification Team
Hello Yushan ZHANG,

Thank you for the report and test case.
Observed that 5.6.48, 5.7.31 and 8.0.21 are affected.

regards,
Umesh