I have a macro  \mywonderfulmacro{...}   that expects an ordinary floating point number in lieu of .... (For example,  \mywonderfulmacro{4.51}   is valid.) Now I would like to do something like this:  \def\a{1.2} \def\b{1.3} \mywondefulmacro{\a * \b}   The hope would of course be that the above code results in  \mywonderfulmacro{1.56}   being evaluated. Unfortunately, TeX doesn't work this way and I get an error!  What is the correct/easiest way to do this?  PS: I know the answer is surely implicit in previous questions/answers to this forum, given sufficient discernment, but my know-how is very low so please I please need an answer that addresses this specific question in this specific situation, not a pointer to some technical post with \the \numexpr and whatnot :/
39025
I am looking for a method to do minimal floating point / integer calculations in LaTeX, not for the purpose of package writing, but for the production of actual text.  Here is an example to illustrate. Given the following input text   The experiment included running a battery of \bind{T}{21} tests  on \bind{S}{13} subjects, for a total of \bind{V}{T*S} expected values.  However, since \bind{F}{37} values were defective, our successful   measurement rate per subject was \use{100*round((V-F)/T,2)}\%   it would be nice if was converted to:   The experiment included running a battery of $21$ tests  on $13$ subjects, for a total of $273$ expected values.  However, since $37$ values were defective, our successful   measurement rate per subject was $86$\%.   Where \bind{C}{expression} defines a new constant C whose value is expression, and returns C, while \use{C} simply returns the value of C.  Any tips?  I am aware of the spreadtab package and this question: , but I am looking for something more.
41749
I'm trying to cache the results of a macro, similar to , but the argument of the macro can contain arbitrary characters and it's not suitable to be inside \csname ... \endcsname.  So, I'm wondering: surely some of the TeX core or packages contain functionality to calculate a hash, MD5 or otherwise (I don't really care which). But… I can't find it. The only result I've got from grep'ing my TeXlive tree is pdfmdfivesum, but it only works on files, not strings.  So: are there ready-made hash calculation macros/packages available somewhere?
53437
Follow-up to the background part in .  In bash I can use ${!FOO} for double substitution, in zsh ${(P)FOO}. In both, the old-school (hack-y) eval \$$FOO works.  So, the smartest and most logical thing for me would be ${${FOO}}, ${${${FOO}}}… for double/triple/n substitution. Why doesn’t this work as expected?  Second: What does the \ do in the eval statement? I reckon it’s an escape, making something like eval \$$$FOO impossible. How to do a triple/n substitution with that that works in every shell?
8137
I have a macro which holds some text value, e.g. \macro{some text}. If it is empty, I would like for nothing to appear in the document, but it has some content of any kind which would produce text displayed in the document, I would like a message to appear, "Text: some text".   \macro{} would be considered empty. \def\somedata{}, \macro{\somedata} would be considered empty. \macro{0} would be considered not empty.   I have tried making a TeX conditional which can check if the value is not empty, but nothing I tried works, e.g.:  \ifx #1 {} \else     Text: #1 \fi  \ifx#1{} \else     Text: #1 \fi  \ifx #1 \nil \else     Text: #1 \fi  \ifx#1!="" \else     Text: #1 \fi   What is the correct syntax for creating a conditional in plain TeX with checks if a value is not empty?
97409
I need to perform a string comparison (string equality). If the macro is non-expandable (e.g. contains \def or \let), it causes problems in the place where it is used.  I tried using \ifthenelse from the package with the same name, but it would seem it is not expandable (the same problems as when I use \def in the macro occur).  \ifthenelse{\equal{a}{b}}{if-case}{else-case}   How can I test the equality of two strings (#1 and a constant, for that matter) in an expandable way?
100626
For example {a..c}{1..3} expands to a1 a2 a3 b1 b2 b3 c1 c2 c3.   If I wanted to print a1 b1 c1 a2 b2 c2 a3 b3 c3, is there an analogous way to do that? What's the simplest way?
113326
If I write a #define that performs an operation using other preprocessor constants, is the final value computed each time the macro appears at runtime? Does this depend on optimizations in the compiler, or is it covered under a standard?  Example:  #define EXTERNAL_CLOCK_FREQUENCY    32768 #define TIMER_1_S                   EXTERNAL_CLOCK_FREQUENCY #define TIMER_100_MS                TIMERB_1_S / 10   Will the operation 32768 / 10 occur at runtime every time I use the TIMER_100_MS macro?  I would like to avoid the following:  #define EXTERNAL_CLOCK_FREQUENCY    32768 #define TIMER_1_S                   EXTERNAL_CLOCK_FREQUENCY #define TIMER_100_MS                3276     Summary  A compiler is required to be able to evaluate constant integral expressions because they are necessary for calculating things like array sizes at compile time. However, the standard only says they "can" -- not "must" -- do so. Therefore, only a brain-dead compiler would not evaluate a constant integral expressions at compile time, but a simple check of the assembly output for an unconventional compiler would verify each case.
76751
I'd like \span to be a math operator (for the  of a set of vectors), but apparently it's already a TeX command. What do you guys recommend I do instead? (I don't really want a strange capital \Span, or some other odd variant... but I'm guessing it's a bad idea to redefine \span?)
48818
I'm using siunitx to input some big numbers and units in my document.  Is there a way to make the output of \num{3.14} be "3,13" instead of "3.13"? In Spanish, we use the first one.
31391
I am trying to give a table cell a grayscale color value based on it's numeric value. So far I have the following code  \documentclass{article} \usepackage{fp,xcolor,colortbl} \FPeval{\resb}{0.5}  \newcommand{\he}[1]{%     \FPeval{\resa}{2 * #1}%     \cellcolor[gray]{\resa}%     #1  }  \begin{document} \begin{tabular}{| c | c | c |}     \hline     \he{0.1} &amp; \he{0.2} &amp; \he{0.3} \\     \hline     \he{0.5} &amp; \he{0.8} &amp; \he{1.0} \\     \hline \end{tabular} \end{document}   The tables contain all floating point numbers. The error I get is :   Undefined control sequence. &lt;argument&gt; \resa    Is there a way I can use the result from the FPeval to color the cell?
42356
I want to change the catcode in a macro, but it seems it doesn't work. Can anyone help me?  \def\A{\catcode`\|=0 |bf{test}}    |bf{test} would not work as expect.
55574
I am using various macros that I have fine-tuned with units like pt and cm. I use those macros normally in certain places (say, in main body text or in footnote text). To properly generalize those macros, I would like to replace the absolute units by relative ones.  Say I have a macro \newcommand*{\aalso}{\textsl{and also}\hspace{1.1pt}}. Say I normally use that macro in footnotes. But now I realize that I made a mistake and would like to change the length 1.1pt to something of the form ...em so that I can use the macro elsewhere. How do I get the right number? I assume that the right way is to define some macro like \emConverter{1.1pt} that, if issued in a footnote context, gives me the length of 1.1pt in a footnote context converted to a relative length in em. It doesn't need to be a LaTeX-parsable value; it's okay if this is just printed out directly into the document, for me to then manually write the new em-value into the source code.  Some relevant questions:
80556
What's going on?! Subtraction works fine until I get to 0.1 - 0.1. I'm in visual c# 2008 using the nonoba.com API.  Console.WriteLine("hit! " + Users[targetNum].character.health + " : " + player.character.profile.attackPower);  Users[targetNum].character.health -= player.character.profile.attackPower;  Console.WriteLine("health! " + Users[targetNum].character.health);   output:  hit! 0.1 : 0.1 health! 1.490116E-08   Thanks all - I might use the decimal type, as I'm normally adding/subtracting nice "round" numbers. For now I'll just go with:  if (Users[targetNum].character.health &lt;= 0.00001)   By the way I knew this wasn't really going to be a "bug" in c# - I thought it would either by a bug in my code or some lack of understanding, which it was.  Having read all the recommended reading, I'm going to conclude that my folly was due to normally using the ActionScript Number type, which maybe has a decimal rather than binary floating point - anyway, it would never give this output.
2827
What's the cleanest, most effective way to validate decimal numbers in JavaScript?  Bonus points for:   Clarity. Solution should be clean and simple. Cross-platform.   Test cases:  01. IsNumeric('-1')      =&gt; true 02. IsNumeric('-1.5')    =&gt; true 03. IsNumeric('0')       =&gt; true 04. IsNumeric('0.42')    =&gt; true 05. IsNumeric('.42')     =&gt; true 06. IsNumeric('99,999')  =&gt; false 07. IsNumeric('0x89f')   =&gt; false 08. IsNumeric('#abcdef') =&gt; false 09. IsNumeric('1.2.3')   =&gt; false 10. IsNumeric('')        =&gt; false 11. IsNumeric('blah')    =&gt; false
30616
I want to print the floating point number with exactly two significant digits in bash (maybe using a common tool like awk, bc, dc, perl etc.).  Examples:   76543 should be printed as 76000 0.0076543 should be printed as 0.0076   In both cases the significant digits are 7 and 6. I have read some answers for similar problems like:      but the answers focus on limiting the number of decimal places (eg. bc command with scale=2 or printf command with %.2f) instead of significant digits.  Is there an easy way to format the number with exactly 2 significant digits or do I have to write my own function?
33293
This is in Windows, but answers for other operating systems can be handy to others.  Most guides say something to the effect of "hold down the Alt key and type in the code on the keypad".  This works fine for decimal codes (like 65 for 'A'), but not for  codes (like  for 'A').  Some applicatons provide other facilities that will allow hexadecimal Unicode character codes to be typed and then transformed.  Word allows you to type the code (such as 200f) and then convert it to Unicode by typing Alt-X.  I'm looking for a general method of doing this that will work with the standard input.
113048
This has sort of been touched on in some other postings, but for path reasons I would like to avoid using a shell script and just use ImageMagick's (IM) convert command line executable directly from a \immediate\write18{...} in a macro command, but in my IM convert instructions I need to pass the % (ASCII 37) as part of a macro.  However I try to conceive of making a % - and I have tried numerous ways(!) I always end up getting the Latex code I am using for the % passed through to the command line.  The obvious one, \% goes to the shell as \% directly and that is the pattern followed by all other options.  What I obviously seem to need is some way to generate the ASCII or unicode for % and get that to the shell from LaTeX via \write18 or other.  Or have some sort of temporary suspension on the LaTeX usage of % so that it can be part of a \write18{} and not break the command as a comment starter, and so be passed with out needing to be LaTeX escaped first.