Is it a bug? Unary operator.

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
jaz99
Posts: 3
Joined: 2012-11-23T02:00:56-07:00
Authentication code: 6789

Is it a bug? Unary operator.

Post by jaz99 »

Hi, I've discovered something strange. The documentation reads:
Unary operators have a lower priority than binary operators, that is, the unary minus (negation) has lower precedence than exponentiation, so -3^2 is interpreted as -(3^2) = -9. Use parentheses to clarify your intent (e.g. (-3)^2 = 9).
Thats is reasonable. But what happens when the unary operator is on the right?

Code: Select all

$ convert -version
Version: ImageMagick 6.8.0-8 2012-12-11 Q16 http://www.imagemagick.org
$ convert xc: -format '%[fx: 10^-2]' info:
0.2
$ convert xc: -format '%[fx: 10^(-2)]' info:
0.01
Should it always be 0.01?

Older version works OK:

Code: Select all

$ convert -version
Version: ImageMagick 6.5.7-8 2012-08-17 Q16 http://www.imagemagick.org
$ convert xc: -format '%[fx: 10^-2]' info:
0.01
JaZ
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Is it a bug? Unary operator.

Post by magick »

We can reproduce the problem you posted and have a patch in ImageMagick 6.8.1-2 Beta available by sometime tomorrow. Thanks.
Post Reply