Skip to content

negative powers() do not raise a DivisionByZeroError  #8015

Closed
@exakat

Description

@exakat

Description

Raising to a negative power is similar to a division, so applying those to 0 should raise a DivisionByZeroError

The following code:

<?php

echo 0 ** -1;
echo 0 ** -2;
echo pow(0, -4);

Resulted in this output:

INF
INF
INF

But I expected this output instead:

PHP Fatal error:  Uncaught DivisionByZeroError: Division by zero

PHP Version

8.1.2

Operating System

N/A

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions