I continue to test the transition from fp to xfp. The results are good but two macros resist: \FPifint and\FPClip. I did not find how to replace them in xfp. I have numbers (decimal numbers [+,-,0,...,9 and "."] only). I want to know if a number is an integer but with the first condition (there is a second ...) :

1.0 , 15.00 etc .. are integers

\FPifint works like this. I found some solutions but not entirely satisfactory and I prefer to avoid loading another package.

  1. biblatex with \ifinteger (not test)
  2. xstring with \IsInteger (I don't need all the stuff)
  3. Memoir with \checkifinteger(wrong solution)
  4. lua with lua_isinteger (not test)

I tried to find a personal solution :

% !TEX TS-program = lualatex-dev

 %xfp because i wanted to use \fpeval for some tests



\foreach \value in {+1 ,-1.00,0.75,10000,0.9998}{
\value{} is considered an integer
\value{} is not considered  an integer


Firstly I'm not sure if my code is correct and I would like to know how to translate this with expl3 (or perhaps the macro comes with xfp ?)

I'm also looking for a macro to remove all unnecessary zeros from a decimal like FPClip

There is another condition: I would like to accept as integers, decimal numbers ending for example with 999. Thus 1.999 or .999 will be considered as decimal. With my code the idea was to test # 2 but I did not find a satisfactory method

enter image description here

  • you can test if round(#1)=#1 or given your final note check that abs(round(#1)-#1)<.001 Jan 5 '20 at 17:46
  • How you write the test with xfp. I don't know the syntax .. There is no example in the doc. Jan 5 '20 at 18:08
  • we are working on the doc but texdoc interface3 then look at the l3fp chapter shows the syntax, I'll post something here. Jan 5 '20 at 18:09

You could just use fpeval and a latex2e test but I use an expl3 conditional here

enter image description here



\fp_compare:nTF{0.01 < abs(round(#1)-#1)}

10 \test{10}{no}{yes}

9.99 \test{9.99}{no}{yes}

1.2 \test{1.2}{no}{yes}

  • It's on my todo list : learn how to use expl3. Thanks it's the beginning of a great learning Jan 5 '20 at 18:43
  • Is it a problem in a package to mix latex2e and expl3 ? Jan 5 '20 at 18:54
  • 2
    @AlainMatthes that is the exact purpose of expl3, to make the l3 programming layer available in 2e documents and packages Jan 5 '20 at 18:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.