Skip to content

Bug: power() returns wrong result for negative exponents #9

@IYENTeam

Description

@IYENTeam

Bug Description

power(2, -3) returns 1.0 instead of 0.125.

Steps to Reproduce

from calculator import power

result = power(2, -3)
print(result)  # Expected: 0.125, Got: 1.0

Expected Behavior

power(2, -3) should return 0.125 (i.e., 2 ** -3).

Actual Behavior

Returns 1.0 because the for loop with range(-3) produces zero iterations.

Environment

  • Python 3.x
  • File: src/calculator.py

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions