raising a negative number to a fractional power yields float
Bug #610877 reported by
Stefano Palazzo
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+
however, this might well be the desired behaviour,
something to investigate.
To post a comment you must log in.
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.