GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [BUG] Pow.pow silently wraps when the result exceeds long range · Issue #7751 · TheAlgorithms/Java

[BUG] Pow.pow silently wraps when the result exceeds long range #7751

New issue
Copy link
New issue
Copy link
Open
#7752
Open
[BUG] Pow.pow silently wraps when the result exceeds long range#7751
#7752
Copy link
Labels
bug

Description

@Prasad-Pitke
Prasad-Pitke
opened on Nov 12, 2026
Issue body actions

Description

com.thealgorithms.maths.Pow.pow(int a, int b) multiplies into a long without checking whether the result is representable. For example, Pow.pow(2, 63) mathematically equals 9223372036854775808, which is greater than Long.MAX_VALUE, but Java long overflow causes the method to return Long.MIN_VALUE. That is a plausible-looking but incorrect result for a utility documented as computing a power and returning a long.

Steps to reproduce

  1. Call Pow.pow(2, 63) (or Pow.pow(2, 64)).
  2. Observe the returned value: Long.MIN_VALUE for the first call, and 0 for the second, due to overflow wrapping.

Excepted behavior

When the exact result cannot fit in a long, the method should detect overflow and report it (for example, by throwing ArithmeticException), or explicitly document wraparound as its intended behavior.

Screenshots

No response

Additional context

No response

Activity

  1. Prasad-Pitke
    added
    bug
    on Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.