On page 1/2 of the xfp package we read:

  • The floating point expressions may comprise:Comparison operators: x < y, x <= y, x >? y, x ! = y etc. However they did not show an example. Below I have an example in which I use \fpeval{\x<\y } to make a decision in a conditional command:

    \usepackage{xfp, ifthen}
    \noindent $x=\fpeval{\x}$.\\
    \ifthenelse{\fpeval{\x<\y }}
     {$x\lt y$}
     {$x\ge y$}

But got an error:

! Missing = inserted for \ifnum. \relax l.10 \ifthenelse{\fpeval{\x<\y }}

Do you know how to fix it?

  • 2
    I think \fpeval is supposed to evaluate to a number. I don't know the full rules, but I'd guess it's 1 if the test is true and 0 otherwise. In that case you'd want \ifthenelse{\fpeval{\x<\y }=1}. If it's 0 if the test is false and non-zero otherwise, you'd probably want to go for \ifthenelse{\fpeval{\x<\y }=0} and invert the logic.
    – moewe
    Aug 14, 2020 at 5:56
  • Great Answer!!! Thanks!!!
    – Aria
    Aug 14, 2020 at 5:59
  • @moewe would you please write ur answer below then I accept it?
    – Aria
    Aug 14, 2020 at 6:00
  • 1
    related Why use xfp rather than fp?
    – AndréC
    Aug 14, 2020 at 6:16

1 Answer 1


The first argument to \ifthenelse must contain a test (by default a test on integer equality).

You could do \ifthenelse{\fpeval{\x<\y}=1}{...}{...} which would return true if \x is actually less than \y.





\ifthenelse{\fpeval{\x<\y}=1}{TRUE}{FALSE} (should be F)

\ifthenelse{\fpeval{\y<\x}=1}{TRUE}{FALSE} (should be T)


enter image description here

With more flexible (and fully expandable) code that I already suggested you



  \bool_if:nTF { #1 } { #2 } { #3 }

\cs_new_eq:NN \numtest     \int_compare_p:n
\cs_new_eq:NN \oddtest     \int_if_odd_p:n
\cs_new_eq:NN \fptest      \fp_compare_p:n
\cs_new_eq:NN \dimtest     \dim_compare_p:n
\cs_new_eq:NN \deftest     \cs_if_exist_p:N
\cs_new_eq:NN \namedeftest \cs_if_exist_p:c
\cs_new_eq:NN \eqdeftest   \token_if_eq_meaning_p:NN
\cs_new_eq:NN \streqtest   \str_if_eq_p:ee
\cs_new_eq:NN \emptytest   \tl_if_blank_p:n
\prg_new_conditional:Nnn \xxifthen_legacy_conditional:n { p,T,F,TF }
  \use:c { if#1 } \prg_return_true: \else: \prg_return_false: \fi:
\cs_new_eq:NN \boolean \xxifthen_legacy_conditional_p:n



\xifthenelse{\fptest{\x<\y}}{TRUE}{FALSE} (should be F)

\xifthenelse{\fptest{\y<\x}}{TRUE}{FALSE} (should be T)


You must log in to answer this question.

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