**Jorg Sowa**— view source

Hello everyone!

I want to start the discussion on the RFC: Raising zero to the power of

negative number

Link: https://wiki.php.net/rfc/raising_zero_to_power_of_negative_number

Kind regards,

Jorg

**Ben Ramsey**— view source

Hello everyone!

I want to start the discussion on the RFC: Raising zero to the power of

negative numberLink: https://wiki.php.net/rfc/raising_zero_to_power_of_negative_number

Kind regards,

Jorg

In Python, the error message for `0 ** -1`

is:

```
ZeroDivisionError: 0.0 cannot be raised to a negative power
```

Instead of "DivisionByZeroError: Division by zero" as the PHP exception

message, could we use a similar message? Something like:

```
DivisionByZeroError: Zero cannot be raised to a negative power
```

I think this will be clearer to a user who encounters this error and

isn't aware that raising zero to a negative power is the equivalent of

dividing by zero.

Cheers,

Ben

**tag Knife**— view source

Hello everyone!

I want to start the discussion on the RFC: Raising zero to the power of

negative numberLink: https://wiki.php.net/rfc/raising_zero_to_power_of_negative_number

Kind regards,

Jorg

IEEE 754 dictates that an infinity should be the expected output for all

these scenarios.

**Ben Ramsey**— view source

Hello everyone!

I want to start the discussion on the RFC: Raising zero to the power of

negative numberLink: https://wiki.php.net/rfc/raising_zero_to_power_of_negative_number

Kind regards,

JorgIEEE 754 dictates that an infinity should be the expected output for all

these scenarios.

If I'm reading the text of IEEE 754-2019 correctly, it means that the

division by zero error should occur when an operation on finite operands

gives an exact infinite result.

"The divideByZero exception shall be signaled if and only if an exact

infinite result is defined for an operation on finite operands."

Cheers,

Ben

**Gina P. Banyard**— view source

Hello everyone!

I want to start the discussion on the RFC: Raising zero to the power of

negative numberLink: https://wiki.php.net/rfc/raising_zero_to_power_of_negative_number

Kind regards,

JorgIEEE 754 dictates that an infinity should be the expected output for all

these scenarios.

IEEE 754 only deals with floating point numbers, and even then if you want IEEE 754 behaviour for division you need to use `fdiv()`

as of PHP 8.0 as any division by 0 throws this error since https://wiki.php.net/rfc/engine_warnings#division_by_zero got accepted.

I think this change makes sense but would rather have an improved wording/Error as proposed by Ben.

Best regards,

Gina P. Banyard

**Jorg Sowa**— view source

Thank you for the suggestions. I agree that error message should be more

meaningful. I changed it.

The main driver of this change is to match the division by zero behavior

for both operators which can operate on both integers and floats. Would it

make sense to create a function `fpow`

similarly to `fdiv`

for the correct

IEEE 754 logic?

Kind regards,

Jorg

**Jorg Sowa**— view source

Hello everyone,

If there is no other feedback I would like to start voting in the next few

days.

Kind regards,

Jorg

**Marc Bennewitz**— view source

Hi Jorg,

Thank you for the suggestions. I agree that error message should be more

meaningful. I changed it.The main driver of this change is to match the division by zero behavior

for both operators which can operate on both integers and floats. Would it

make sense to create a function`fpow`

similarly to`fdiv`

for the correct

IEEE 754 logic?

As of your note of consistent behavior here, in your RFC I don't see any

note about operating on float - It's all about int. It would be good to

explicitly describe both int and float behavior in your RFC.

About `fpow`

- I personally never felled the need to use `fdiv`

but as

`fdiv`

was explicitly introduced to expose IEEE-754 semantics I think it

totally makes sense to add `fpow`

as well.

Greetings,

Marc

Kind regards,

Jorg