# What is the correct way of calling fp rand and randint?

All my attempts to use floating point functions rand(), and randint(...,...) for that matter, are failing. Using exactly the same syntax for other fp functions, for example trunc(), sind(), etc. produces the expected result. What am I missing with rand()?

\documentclass{article}
% RN. 8 April 2017
% BRIEF DESCRIPTION:
%  my code produces -ERROR: Unknown fp word rand-. What am I missing???
%=======================
\usepackage[check-declarations]{expl3}
\usepackage{xparse}
%-----------------------
\ExplSyntaxOn
\NewDocumentCommand\myRandomNumber{}
{
\fp_eval:n {rand()}
}
\ExplSyntaxOff
%-----------------------
\begin{document}
\myRandomNumber
\end{document}

• The rand() function has been added in December 2016, so you need a newer version of xparse. Your example runs for me without errors – user31729 Apr 8 '17 at 14:40
• The docs say New: 2016-12-05: can you add \listfiles and edit in the File list from the .log. – Joseph Wright Apr 8 '17 at 15:33
• @Christian hupfer I am working with MikTex 2.9and the package manager shows the L3kernel with a 2016-11-22 time stamp. So far so good. Invoking Miktex Update I am informed that L3kernel, L3experimental, L3packages and a number of other packages I am using regularly are obsolete and ought to be removed, without any indication of what will replace them. This looks like the kind of update that could leave me sitting in a deep hole. What is your advice? – Reinhard Neuwirth Apr 8 '17 at 21:54
• @ReinhardNeuwirth: Well, if you want to use the rand functions you need to update. Apparently you got aware of the new features anyway. You accepted David's answer which is telling you basically the same: 'up to date system' or 'xfp' package – user31729 Apr 8 '17 at 21:56
• @Christian hupfer All done, runs like clock-work. Thanks. – Reinhard Neuwirth Apr 8 '17 at 22:39

Your code should make no error with an up to date system, but with an up to date system you can simplify it further using the new xfp package which exposes \fp_eval:n as a document level command \fpeval

\documentclass{article}

\usepackage{xfp}

\newcommand\myRandomNumber{\fpeval{rand()}}

%-----------------------
\begin{document}
\myRandomNumber
\end{document}