[MDEV-30546] The representation of 0 in division function in computing string Created: 2023-02-02  Updated: 2023-02-02  Resolved: 2023-02-02

Status: Closed
Project: MariaDB Server
Component/s: Data types
Affects Version/s: 10.9.4
Fix Version/s: N/A

Type: Bug Priority: Minor
Reporter: 王瑞丰 Assignee: Sergei Golubchik
Resolution: Not a Bug Votes: 0
Labels: None
Environment:

mariadb docker


Issue Links:
Duplicate
duplicates MDEV-6856 <negative value> MOD <fractional divi... Open

 Description   

When we use the division function to calculate, we find that if there is a negative number type string, the result will be inconsistent with the expectation

select 0/-4; – actual: 0.0000, expect: 0
select '0'/-4; – actual: -0, expect: 0

MySQL has verified this as a bug. please see https://bugs.mysql.com/bug.php?id=109837. so I consider it also a bug for mariadb.



 Comments   
Comment by Sergei Golubchik [ 2023-02-02 ]

It's partially "not a bug" and partially a duplicate.

select 0/4, 0/-4

both results are of DECIMAL type, @@div_precision_increment applies.

select '0'/4, '0'/-4

the result is DOUBLE with not fixed precision, so it's printed as 0. Negative zero is MDEV-6856

Comment by Sergei Golubchik [ 2023-02-02 ]

I'm closing it as "not a bug" because the main complain is (it's clearer in MySQL bug report) that "We believe that 0 and '0' can be regarded as the same during type conversion".

Generated at Thu Feb 08 10:17:04 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.