Page 1 of 1

possible bug in fx calcs in HDRI Q32

Posted: 2010-08-11T20:03:03-07:00
by fmw42
If I do the following in IM 6.6.3.4 Q16 HDRI Mac OSX Tiger,


gain1=`convert xc:gray -format "%[fx:1/maxima]" info:`
echo "gain1=$gain1"

convert xc: -format "%[fx:quantumrange]" info:
max=`convert xc:gray -format "%[max]" info:`
echo "max=$max"
gain2=`convert xc: -format "%[fx:quantumrange/$max]" info:`
echo "gain2=$gain2"


Then I get gain1=gain2=2

But if I do the same in Q32 HDRI, I get

gain1=2.02381
gain2=2.02381e+18

I think the fx calc has problems with both numerator and denominator are in scientific notation, as here we have:

QuantumRange=4.29497e+09
and
max=2.12222e+09


and

gain2=4.29497e+09/2.12222e+09

which should be about 2, but ends up as 2.02381e+18. Looks like the two e+9 are added to get e+18 rather than subtracted to get e+0

Re: possible bug in fx calcs scientific notation

Posted: 2010-08-11T20:48:09-07:00
by fmw42
Here is a simple test:


val1=2e+6
val2=1e+5
convert xc: -format "%[fx:$val1/$val2]" info:
2e+11

but it should be 20 or 2e+1

This may just be a case of FX calcs using scientific notation and not related to HDRI or Q32.

PS. I get the same bad result above in Q16 HDRI AND Q16 non-HDRI. So it looks like it is an fx calc problem that is not HDRI limited.

Re: possible bug in fx calcs in HDRI Q32

Posted: 2010-08-12T17:45:55-07:00
by magick
We can reproduce the problem you posted and have a patch in ImageMagick 6.6.3-5 Beta available by sometime tomorrow.

Re: possible bug in fx calcs in HDRI Q32

Posted: 2010-08-14T22:53:01-07:00
by fmw42
This works in IM 6.6.3.6 Q16 HDRI

val1=2e+6
val2=1e+5
convert xc: -format "%[fx:$val1/$val2]" info:
20

Thanks.