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

ROUND(double) is inconsistent about fractional digits

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Minor
    • Resolution: Unresolved
    • 5.3.12, 5.5.36, 10.0.9
    • 5.5
    • None
    • 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.

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.