Skip to content

power(decimal, integer) overflow for moderate exponents #22480

Closed

Description

@neilconway

Describe the bug

power(decimal, integer) computes base ^ exp on the unscaled integer representation and then normalizes, which leads to overflows before normalization for reasonably sized inputs.

To Reproduce

SELECT power(2.5::decimal(20, 4), 10);
-- Arrow error: Arithmetic overflow: Cannot raise base 25000 to exp 10

Expected behavior

DuckDB:

memory D SELECT power(2.5::decimal(20, 4), 10);
┌────────────────────────────────────────┐
│ power(CAST(2.5 AS DECIMAL(20, 4)), 10) │
│                 double                 │
├────────────────────────────────────────┤
│                        9536.7431640625 │
└────────────────────────────────────────┘

Postgres returns the same.

Additional context

No response

Activity

  1. added theissue type on May 23, 2026
  2. neilconway commented on May 23, 2026

    @neilconway
    ContributorAuthor

    take

  3. added a commit that references this issue on Jun 4, 2026
    7ed9a0b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions