potential bug in fx log2 IM 6.4.3-6

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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

potential bug in fx log2 IM 6.4.3-6

Post by fmw42 »

IM 6.4.3-6 Q16 Mac OSX Tiger

The recently added log2 function to fx does not seem to work:

convert rose: -format "%[fx:log(w)]" info:
1.8451

convert rose: -format "%[fx:ln(w)]" info:
4.2485

convert rose: -format "%[fx:log2(w)]" info:

convert: missing expression `'.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: potential bug in fx log2 IM 6.4.3-6

Post by magick »

Sigh. The crappy parser thinks of log2 as log*2. Come up with a name for log2() that does not have a number in it and we will apply a patch to the Subversion trunk (e.g. logdeux() works).
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: potential bug in fx log2 IM 6.4.3-6

Post by el_supremo »

How about logbin() or logbinary() ?

Pete
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: potential bug in fx log2 IM 6.4.3-6

Post by fmw42 »

magick wrote:Sigh. The crappy parser thinks of log2 as log*2. Come up with a name for log2() that does not have a number in it and we will apply a patch to the Subversion trunk (e.g. logdeux() works).
How about logtwo()?

From Wikipedia:
binary logarithm (log2; sometimes lg, lb, or ld), in computer science and information theory

So other suggestions are: logb or lb (don't really like that) or ( logbin per el_supremo )

My preference, I guess, would be either logb() or logtwo(), but I can live with logbin() also (but logb is shorter)

el_supremo, Anthony or any one else - do you have a preference from any of these?

By the way, there is a workaround so this is not urgent:

log2(x) = log(x)/log(2)


FYI: the reason this came up to begin with was in response to viewtopic.php?f=1&t=11979
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: potential bug in fx log2 IM 6.4.3-6

Post by magick »

We changed it to logtwo() for now. If you have another preference, let us know.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: potential bug in fx log2 IM 6.4.3-6

Post by fmw42 »

magick wrote:We changed it to logtwo() for now. If you have another preference, let us know.

That is fine with me. If others have a preference, let them speak out quickly.
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: potential bug in fx log2 IM 6.4.3-6

Post by el_supremo »

No problemo

Pete
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: potential bug in fx log2 IM 6.4.3-6

Post by anthony »

I would not worry about a log2() or logtwo()
better to use log(number)/log(base) in any case!
the base being a constant if you want it in a loop!

It is basically how log2 and log10 work in any case.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: potential bug in fx log2 IM 6.4.3-6

Post by fmw42 »

anthony wrote:I would not worry about a log2() or logtwo()
better to use log(number)/log(base) in any case!
the base being a constant if you want it in a loop!

It is basically how log2 and log10 work in any case.

That is how I am already doing it now (as a workaround). But Magick had built a log2() function in -fx (to make things cleaner/simpler) and this is just a fix of the name as having a numeral in the log2() name caused problems. See my earlier post.
Post Reply