Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-23702

calculating(auto rounding) issue

    XMLWordPrintable

    Details

      Description

      I'm not sure this is a bug or not, because there is no such configuration like auto round points.
      I thought it connect to div_precision_increment. but seems not

      all test configuration is same

      MariaDB [(none)]> show variables like '%prec%';
      +-------------------------+-------+
      | Variable_name           | Value |
      +-------------------------+-------+
      | div_precision_increment | 4     |
      +-------------------------+-------+
      

      MariaDB 10.3.24 && 10.4.14

      MariaDB [(none)]> select (55/23244*1000);
      +-----------------+
      | (55/23244*1000) |
      +-----------------+
      |          2.4000 |
      +-----------------+
       
      select cast( (55/23244*1000) as decimal(5,4));
      +----------------------------------------+
      | cast( (55/23244*1000) as decimal(5,4)) |
      +----------------------------------------+
      |                                 2.4000 |
      +----------------------------------------+
       
      MariaDB [(none)]> set div_precision_increment=8;
      Query OK, 0 rows affected (0.000 sec)
       
      MariaDB [(none)]> select cast( (55/23244*1000) as decimal(5,4));
      +----------------------------------------+
      | cast( (55/23244*1000) as decimal(5,4)) |
      +----------------------------------------+
      |                                 2.3662 |
      +----------------------------------------+
       
      MariaDB [(none)]> select (55/23244*1000);
      +-----------------+
      | (55/23244*1000) |
      +-----------------+
      |      2.36620000 |
      +-----------------+
      

      MariaDB 5.5 ~ 10.3.22

      MariaDB [(none)]> show variables like '%prec%';
      +-------------------------+-------+
      | Variable_name           | Value |
      +-------------------------+-------+
      | div_precision_increment | 4     |
      +-------------------------+-------+
       
      MariaDB [(none)]> select (55/23244*1000);
      +-----------------+
      | (55/23244*1000) |
      +-----------------+
      |          2.3662 |
      +-----------------+
       
      MariaDB [(none)]> select cast( (55/23244*1000) as decimal(5,4));
      +----------------------------------------+
      | cast( (55/23244*1000) as decimal(5,4)) |
      +----------------------------------------+
      |                                 2.3662 |
      +----------------------------------------+
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              serg Sergei Golubchik
              Reporter:
              leciel leo cardia
              Votes:
              1 Vote for this issue
              Watchers:
              8 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: