raising a negative number to a fractional power yields float

Bug #610877 reported by Stefano Palazzo
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Pycalc
Won't Fix
Undecided
Unassigned

Bug Description

-12**0.2 yields -1.64375182952 whereas it should result in (1.32982316461+0.966173083819j)
however, this might well be the desired behaviour,
something to investigate.

Revision history for this message
Stefano Palazzo (stefano-palazzo) wrote :

it is indeed desired.

Python 2.x raises "ValueError: negative number cannot be raised to a fractional power" if one tries to.

The expression -12**0.2 is evaluated as -(12**0.2), rather than (-12)**0.2, which is valid in python3000 and returns the correct complex result.

to counter those effects in pycalc, any expression would have to be changed in such a way that expected precedence is lost. It also would be rather complicated.

talking maths now, the true definition of negative roots depends on the intention of the calculation. it could be that a real result is wanted for an even root of a negative real number, it could also be a complex result is needed. The current behaviour therefore seems appropriate.

Changed in pycalc:
status: New → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.