vincentb1 / fmtcount

Source for LaTeX fmtcount package
11 stars 5 forks source link

floating point numbers crash \numberstringnum #19

Open vv01f opened 9 years ago

vv01f commented 9 years ago

used in German language here would expect \numberstringnum{31,50} to return "einunddreißig komma fünfzig" ("thirtyone point fifty") for currency or "einunddreißig komma fünf null" ("thirtyone point fife zero") for e.g. measures any solution I missed?

nlct commented 9 years ago

The commands provided by fmtcount all require integer values. (They're primarily provided for use with counters, which use integer registers.) There's no support for floating point numbers.

vv01f commented 9 years ago

then maybe you can make it give a nicer hint or error message what went wrong in case someone like me tries to abuse the package :)

nlct commented 9 years ago

Unfortunately TeX doesn't really have a concept of type checking. The same problem occurs with other commands that require an integer. For example, with the following:

\documentclass{article}

\begin{document}

\newcounter{test}
\setcounter{test}{2.5}
Counter: \thetest.

\end{document}

there's no error message, but a spurious .5 appears in the document. Whereas

\documentclass{article}

\newcounter{test}
\setcounter{test}{2.5}

\begin{document}
Counter: \thetest.
\end{document}

produces the somewhat puzzling message ! LaTeX Error: Missing \begin{document}. (Because of the spurious .5.)

The \numberstring / \numberstringnum commands are all analogous to LaTeX's \roman / \@roman commands which likewise require integers, but don't perform any checking that the argument is actually an integer register / number.

I think the best thing to do is to clarify in the manual that by "number" we mean an integer number.

vincentb1 commented 9 years ago

What you wrote is correct for the German language implementation which uses counters under the hood. But for the French language I have redesigned the implementatkion based on fcnumparser.sty, and it has the possibility to detect decimal separator, even though currently formatting decimal number is not supported.

Anyhow, I am still too busy with other items…