On page 1/2 of xfp package we see x >? y as a valid comparison operator. Is it different from x>y? I think they are equivalent based on my following code, but not sure:




\fpeval{\x>? \y}\\
\fpeval{\x> \y}

The result for both is zero. So are they equivalent in general?

  • May I ask where to find the documentation for x ?y
    – Aria
    Aug 14, 2020 at 7:53
  • 1) \fpeval is just a wrapper of latex3 function \fp_eval:n (documented in interface3) which accepts a floating point expression. 2) From the doc, sec. XXIII.9.3, a relation operator should consists of a non-empty string of <, =, >, and ?, optionally preceded by !, and may not start with ?. 3) Hence \x >? \y means if \x is greater than or not ordered with \y. Aug 14, 2020 at 8:05
  • @HenriMenke Thanks for pointing out that. I should be more cautious. Aug 14, 2020 at 8:07

1 Answer 1


The question mark ? is the “not ordered” comparison of l3fp. More or less quoting from the documentation of \fp_compare_p:nNn:

x ? y is true if x and y are “not ordered” which occurs exactly if one or both operands is nan or is a tuple. Note that nan is distinct from any other value, even from itself, i.e. if x = nan then x == x is false. To test whether a value is nan you can use the “not ordered” comparison with any other value, e.g. x ? 0.

That also means that if neither x nor y are nan or a tuple, the comparison x >? y will be equivalent to x > y.

Personal note: I'm rather skeptical of the usefulness of this “not ordered” comparison. It seems to me that this is trying to solve a problem that is already covered by other operators. For example in a traditional programming language, like C, you can check for nan by checking whether a value is equal to itself, i.e. x == x will only ever be false, if x is nan. For comparison between tuples, all operators should just return false (or better throw a type error), except for == and != which ought to perform and element-wise comparison.

  • Would you please put a link you quoted from l3fp?
    – Aria
    Aug 14, 2020 at 8:06
  • 1
    @Aria No, the interface3.pdf documentation doesn't have stable hyperlink targets, so the next time it updates, the link will be wrong. For now you can use this link: mirror.ctan.org/macros/latex/contrib/l3kernel/… Aug 14, 2020 at 8:08
  • 2
    Enrico ('egreg') is working on a proper user documentation file for xfp, as it's a bit terse ATM
    – Joseph Wright
    Aug 14, 2020 at 9:16
  • 1
    I'm sorry to ask such trivial questions, but I didn't understand. What in practice is an “not ordered” comparison? What is a “ordered” comparison ? What is nan?
    – AndréC
    Aug 15, 2020 at 9:21
  • @AndréC Please refer to the great article What Every Computer ScientistShould Know About Floating PointArithmetic (or just Google?) for these details. Aug 15, 2020 at 9:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .