# Can \fp_eval handle uppercase e (“E”) exponent symbol format

While handling data from a text file, I stumbled upon this problem.

My numeric data is formatted using a %n.dE C format specifier. which outputs numbers with a uppercase e (E) as scientific notation exponent character. While the lowercase e situation works fine, the floating point calculation seems to fail with these major E characters.

I know the best solution would be to symply change the write format specifier, but I think that there is a bug in the generating software, which prevents me to correct this.

I there an option for the fp module to correct this ? I can't find the documentation for this.

Here is an example throwing the problematic error

\documentclass[border=3.14mm]{standalone}
\usepackage{xparse}
\ExplSyntaxOn
\DeclareExpandableDocumentCommand \eval { m } { \fp_eval:n { #1 } }
\ExplSyntaxOff

\begin{document}
\eval{123456789}
\eval{1.23456789}
\eval{1.23456789e3}
\eval{1.23456789E3}
\end{document}


• Thanks for the question. The next version of l3fp should allow for uppercase E exponent marker: I've just pushed the change to our code repository. – Bruno Le Floch Apr 18 '20 at 19:52
• @BrunoLeFloch That's great, thanks ! – BambOo Apr 18 '20 at 20:48

You can programmatically lowercase the string:

\documentclass[border=3.14mm]{standalone}
\usepackage{xparse}
\ExplSyntaxOn
\NewExpandableDocumentCommand \eval { m } { \fp_eval:n { \str_lowercase:n { #1 } } }
\ExplSyntaxOff

\begin{document}
\eval{123456789}
\eval{1.23456789}
\eval{1.23456789e3}
\eval{1.23456789E3}
\end{document}

• I took the liberty to change Declare into New: it's preferable, because it checks whether the command is already defined. – egreg Apr 15 '20 at 12:16
• @egreg much appreciated! (I hadn't really look too much at the code to be honest, only copied it over and added the \str_lowercase:n) – Skillmon Apr 15 '20 at 12:22
• As simple as that. Thanks – BambOo Apr 15 '20 at 12:41