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

ROUND(double) is inconsistent about fractional digits

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 5.3.12, 5.5.36, 10.0.9
    • Fix Version/s: 5.3.13, 10.0, 5.5
    • Component/s: None
    • Labels:
      None

      Description

      For a double type argument,
      ROUND(1e0, N) returns N fractional digits when N is <31,
      and 0 fractional digits when N is >=31.

      +--------------+----------------------------------+---------------+----------------+
      | ROUND(1e0,5) | ROUND(1e0,30)                    | ROUND(1e0,31) | ROUND(1e0,100) |
      +--------------+----------------------------------+---------------+----------------+
      |      1.00000 | 1.000000000000000000000000000000 |             1 |              1 |
      +--------------+----------------------------------+---------------+----------------+
      

      For a decimal type argument ROUND(1.0,N) works differently:

      +--------------+----------------------------------+----------------------------------+----------------------------------+
      | ROUND(1.0,5) | ROUND(1.0,30)                    | ROUND(1.0,31)                    | ROUND(1.0,100)                   |
      +--------------+----------------------------------+----------------------------------+----------------------------------+
      |      1.00000 | 1.000000000000000000000000000000 | 1.000000000000000000000000000000 | 1.000000000000000000000000000000 |
      +--------------+----------------------------------+----------------------------------+----------------------------------+
      

      It returns N fractional digits for N<31, and 30 fractional digits for N>=31.

      Not sure which is more correct, but it would be nice to have
      similar behaviour for the two data types.

        Gliffy Diagrams

          Attachments

            Activity

            There are no comments yet on this issue.

              People

              • Assignee:
                bar Alexander Barkov
                Reporter:
                bar Alexander Barkov
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated: