Using != in \pgfmathparse

In section 63.1 Operators of the pgf manual pgfmanual.pdf I see the claim that

x != y returns 1 if x ≠ y, 0 otherwise.

Unfortunately, I can't get that to work:

\documentclass{article}
\usepackage{pgf}
\pgfmathparse{3!=4}


gives me a Missing \begin{document} error, but replacing != by <= works.

Is this a bug in pgfmath, or a misunderstanding on my part? (This may be related to the factorial operator being ! too.)

-
\pgfmathnotequal{3}{4} or \pgfmathparse{notequal(20,25)} maybe? MATLAB took over the CPU so I can't test :) – percusse Jan 10 '12 at 3:08
This is "because" your command actually writes 34 to the input, as can be seen by putting it after \begin{document}. Also, it sets \pgfmathresult = 4. This seems like it does not agree with the specification, so I would call it a bug, but as I cannot understand how pgfmathparse works, I don't want to glorify that judgment by phrasing it as an answer. – Ryan Reich Jan 10 '12 at 3:23

There seems to be an error in pgfmathparser.code.tex. Line 712 of the latest version (1.47) reads

\pgfmathdeclareoperator{!=}{notequalto}{2}{infix} {250}


but it should be

\pgfmathdeclareoperator{!=}{notequal}{2}{infix} {250}


since the function is called notequal (not notequalto). Changing this line fixes the problem. I'll file a bug report.

-
Oh, that makes sense. Somewhere in the code is written something like \csname pgf@operator@!=@name\endcsname which is no doubt applied to the arguments {3}{4}. Since the former expands to \notequalto, which does not exist, it turns into \relax and the arguments are dumped to the input. Meanwhile \pgfmathresult has been set internally and was not properly reset, so ends up as 4 somehow. – Ryan Reich Jan 10 '12 at 3:46
Fixed in the cvs repository. Thanks for the report and the fix. An updated version of pgf-cvs should become available in the tlcontrib repository in a few days. – cjorssen Jan 10 '12 at 8:42
@cjorssen: Wow, that was quick! And so convenient, without even going through the bug tracker! Thanks! – Jake Jan 10 '12 at 9:10